By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

How to invoke an STA delegate from an MTA thread? Is marshaling required?

P: 8
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 another thread to execute as an STA thread when called from an MTA thread? Is marshaling required?
Apr 18 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.