C# Thread and what does it mean to set ApartmentState.STA or ApartmentState.MTA

T.Zacks 3,996 Reputation points
2022-02-21T18:24:52.477+00:00

I do not know what happen when we set STA & MTA for thread. please tell me if i set mythread.SetApartmentState(ApartmentState.STA); then what will happen ?

and same way if i set mythread.SetApartmentState(ApartmentState.MTA); then what will happen ?

1) what is difference between ApartmentState.STA & ApartmentState.MTA ?
2) thread state default is MTA but if i set STA then what will change in execution flow of thread?

looking for a good guide line. thanks
Thanks

Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2022-02-21T18:45:48.157+00:00

    You can find some explanations in this extract of a book : ApartmentState

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.