I am implementing an interface that has a BeginSomething()
and EndSomething()
pair, and my implementation is in a method Execute()
So I create an Action action = Execute
, and call action.BeginInvoke
in BeginSomething, and action.EndInvoke
in EndSomething. However my Execute method has to be called by a thread whose apartment state is STA (single-threaded apartment). Usually this is done by calling Thread.SetApartmentState
, but in this case I don't know which thread is going to invoke my method.
How should I make the calling thread STA?