Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

PrintDialog : "The calling thread cannot access this object because a different thread owns it"

$
0
0

I'm trying to write a service that act as a print spooler : it waits for documents to print and print the on the right printer with the right settings (stored in a PrintTicket).

Each time a bunch of document is coming a thread is created for each setting and the documents are printed in parallel in their thread.

It works when I use a WPF application, but when I use the same code in a windows service I sometimes get this error on the PrintDialog.PrintVisual function call :

the calling thread cannot access this object because a different thread owns it

When googling for this error I often end up with this thread safe print dialog, but it doesn't provide the PrintVisual function.

Any other idea on how to get rid of this error ?

Thanks for your help


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>