Windows Develop Bookmark and Share   
 index > Windows Forms Designer > COM Interopt - is it all STA or single threaded?
 

COM Interopt - is it all STA or single threaded?

Question - 

I'm using the "AxWebBrowser" component and it's requiring that I create the instance using the STA model in my Main() method for my hosting WinForm.

Are all Interopt compoenets STA?  

And if not is there a way that I can either:

A) modify the compoent so that I can use MTA
B) a better web browser component that does support MTA.

Thanks!

Viking
MigrationUser 1  Thursday, March 06, 2003 6:32 PM
It is all STA.  In fact, Windows Forms supports only STA threaded applications.  Running in MTA mode can yield results that can best be described as "undefined"

 - mike
MigrationUser 1  Friday, March 07, 2003 2:59 AM
Most COM objects (WebBrowser included) are STA, as is the Win32 API itself.  If you need to use other threads here, you are best off doing as much work as possible in them and then marshalling over batch updates to the UI thread using Control.Invoke/BeginInvoke.  

The only legal Windows Forms call from a thread other than the one that created the control is Control.Invalidate.
MigrationUser 1  Tuesday, March 11, 2003 5:35 PM
Well, this made me look at the docs, 'cause I wondered how I had missed this particular method call being threadsafe. The docs for InvokeRequired say:

"There are four methods on a control that are safe to call from any thread: Invoke, BeginInvoke, EndInvoke and CreateGraphics. For all other method calls, you should use one of these invoke methods when calling from a different thread."

Is there a discrepancy here? Am I missing something? I'm guessing that you're right, and the docs are incomplete.

Just wondering, 'cause I do a lot of public blabbing on threading in Windows forms, it seems... <g> Thanks!
MigrationUser 1  Wednesday, March 12, 2003 9:48 AM

You can use google to search for other answers

Custom Search

More Threads

• How to SET the client rectangle of a windows Form?
• ControlArray
• Printing a windows form page
• Screen Refresh Problem
• Capture OnDragOver
• Sort DataGrid View on the basis of CheckBox Column
• operating system supports for Visual Studio 2003 and 2005
• Visual inheritence problem
• this thread is closed
• Design-time property with no designer transactions: possible?