I am trying to provide a preview of XPS documents without freezing my UI thread. Opening a document is fast enough, but when I call GetFixedDocumentSequence (), my user interface stops responding for several seconds while the document is being cleaned.
XpsDocument doc=new XpsDocument("BigFile.xps",FileAccess.Read);
FixedDocumentSequence seq=XpsDocument.GetFixedDocumentSequence();
The obvious solution is to open the document in the workflow, but FixedDocumentSequence is bound to the thread that created it, so I cannot access it from the UI thread, and if I try to call GetPageAsync on the work thread, I get an exception because DocumentPages contains visual effects.
The only thing I can think of is to create the document in a separate user interface thread, paginate the document and then save these pages as XPS files that the user interface thread will open. But this seems like a terribly difficult decision. Does anyone know if there is an alternative way to get DocumentPages that doesn't rely on FixedDocumentSequence?
source
share