Printdialog in multithreaded wpf window thrown TargetInvocationException

Posted by Nils on Stack Overflow See other posts from Stack Overflow or by Nils
Published on 2010-06-04T08:22:26Z Indexed on 2010/06/08 8:22 UTC
Read the original article Hit count: 246

Filed under:
|
|

I have designed a multithreaded app, which is starting most windows in an dedicated thread like this:

Thread newWindowThread = new Thread(new ThreadStart(ThreadStartingPoint));
newWindowThread.SetApartmentState(ApartmentState.STA);
newWindowThread.IsBackground = true;
newWindowThread.Start();

However, if in one of those window-in-own-thread I try to print something by simply calling

PrintDialog pDialog = new PrintDialog();
bool? doPrint = pDialog.ShowDialog();

I get a TargetInvocationException - it does look like the PrintDialog does not reside in the same thread as my window.

Is there any way to create a thread-agnostic (or "thread-save") PrinterDialog ?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about multithreading