1
votes

My project has several hardware components that have to work together.

I have as part of my project a BlackMagic Decklink video card which I have successfully accessed via the BlakcMagic SDK.

I developed a user control in a separate project and now I want to integrate that code with my main project.

The only problem I have is that the BlackMagic interface requires MTA model, the main project is an STA model and due to the other hardware interface, has to stay that way.

My question is, how can I substantiate an instance of an MTA user control in an STA environment?

1
That is not possible, a UserControl must always run in an STA thread. You need to create your own Thread, create the COM object on that thread.Hans Passant
Thanks for the help, but I figured out how to make it work. I added the qualifier [MTAThread] in front of the methods which instantiated the object along with any callbacks. My MTA usercontrol is now working within the STA environment.EinsteinKiller
No, that doesn't do anything. The attribute is only valid on the Main() entrypoint. Which must be [STAThread] for a GUI app. That we have absolutely no idea what actually went wrong does not help us help you.Hans Passant

1 Answers

-1
votes

The trick here is to add the statement:

[MTAThread]

in front to the Load method of the parent. In this case, I encapsulated the usercontrol in another form, and added the statement in front of form_load(){}.

The resulting UserControl then existed in the MTA model.