Starting an STAThread in C#
问题 I am still kind of new to C#, and especially threading in C#. I am trying to start a function that requires a single threaded apartment (STAThread) But I am not able to compile the following code: The function looks as follows in a separate class called MyClass : internal static string DoX(string n, string p) { // does some work here that requires STAThread } I have tried the attribute [STAThread] on top of the function but that does not work. So I am trying to create a new Thread as follows: