Search code examples
.netmultithreadingprintdialog

How can open print dialog box in another thread


If i simply call

If PrintDialog1.ShowDialog = DialogResult.OK Then
                                        PrintDocument1.Print()
                                    End If

its working fine but if i use this function in another thread then it will shows error

{"External component has thrown an exception."}


Solution

  • Create object of PrintDialog in new thread & then call

    Dim myPDia As New PrintDialog
     If myPDia.ShowDialog() = Windows.Forms.DialogResult.OK Then
        PrintDocument1.Print()
     End If