Loading and viewing my xps document works just fine but it takes a long time to load the document and as you know it causes the UI to look inactive.
XpsDocument xpsDocument = new XpsDocument(@"Resources\maintManual.xps", FileAccess.Read);
documentViewer1.Document = xpsDocument.GetFixedDocumentSequence();
So, I am trying to load the document through the backgroundworker:
private void maintBtn_TouchDown(object sender, TouchEventArgs e) // load and view maint manual
{
BackgroundWorker worker = new BackgroundWorker();
worker.WorkerReportsProgress = true;
worker.DoWork += worker_DoWork;
worker.ProgressChanged += worker_ProgressChanged;
worker.RunWorkerCompleted += worker_RunWorkerCompleted;
worker.RunWorkerAsync();
}
void worker_DoWork(object sender, DoWorkEventArgs e) // do work
{
XpsDocument xpsDocument = new XpsDocument(@"Resources\maintManual.xps", FileAccess.Read);
documentViewer1.Document = xpsDocument.GetFixedDocumentSequence();
}
As soon as the "Dowork" is executed the ui "crashes" (locks up totally). I can't seem to find why. Is there a better way to call the document via the background worker? Like I said, the code in the Dowork brackets works just fine outside of the background worker on it's own, so I know the code is right. Once the background worker is used, it stops working. Please forgive me in advance if I didn't include enough information. I am junior coder and new to this site.