Asked by:
XmlSchemaSet Add async problem

-
When loading a schema through:
Dim settings As XmlReaderSettings = New XmlReaderSettings() settings.Async = True Dim reader As XmlReader = XmlReader.Create(inputUri, settings) xmlSchema = xmlSchemaSet.Add(Nothing, reader)
The schema defined in the
inputUri
variable resolves using then properGetEntityAsync
function of the XmlUrlResolver. But the imported schemas resolve synchronously, which causes my ui to freeze while the schemas are being retrieved.How do I make the automatic imports schema (provided during the XmlSchemaSet.Add method) retrieval asynchronous?
Thanks,
Kingman B
Question
All replies
-
-
-
Hi,
I think you need to try Viorel_'s solution to solve your problem,see the link:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/await
Best Regards,
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
-
Hi Alex,
Using Viorel_'s solution would free up the UI, but what I would like (if possible) is for the XmlSchemaSet.Add method to add the imported schemas asynchronously. There are two reasons for this:
1. I use a progress bar to inform the user the status of the schema (and imported schema) loading. As the imports are starting to load, they report the size of the stream (if possible). If the load was asynchronous, the next import in queue would start to load and report its length, increasing the total bytes requested and the denominator of the progress bar percentage complete calculation. As bytes are read, the numerator increases, moving the progress bar forwards. This method works well as I have written my own version of a XmlSchemaSet manager using asynchronous reads. I just want to use the .Net version because it is faster.
2. When I wrote my own version I noticed significant time savings when I went "full async". I'd like to see the same from the XmlSchemaSet.Add. If an XmlSchema had 10 or so imports, asynchronous loading was over twice as fast.
Thanks,
Kingman
-
Hi,
I have no good advice.
Best Regards,
Alex
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.