Printdialog in multithreaded wpf window thrown TargetInvocationException
- by Nils
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 ?