Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to invoke an STA delegate from an MTA thread? Is marshalling requi

Status
Not open for further replies.

ProtocolPirate

Programmer
Nov 21, 2007
104
US
In a background worker threads are MTA, while UI threads must be STA. Attempting to instantiate a form class in a background worker throws an exception, so invocation of a delegate is required.

My problem is that I have encapsulated all of my twain driver code into a plain class with no form which I instantiate in the background worker. If the scanner is not loaded I need to display a simple dialog, so I created a delegate on the main form, but when I call My.Forms.Form1.myDialogDelegate.Invoke(), the delegate reports that it's apartment state is MTA and it still will not display a dialog.

How can I force a delegate call to execute in an STA thread?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top