c# - Is STAThread attribute a requirement or recommendation? -


i wrote managed extension autocad. when autocad loads extension launch iextensionapplication.initialize() method. need method launched in main thread of application. enough set stathread attribute method purpose? attribute requirement or recommendation?

the [stathread] attribute works on main() entrypoint of standalone executable program. promise make operating system, telling main thread of program "well-behaved". must pump message loop , never block. breaking promise causes hard diagnose misbehavior, deadlock common.

none of applies when write autocad extension. did not create thread, autocad did. can't make promises, autocad has implement them. nor "main thread", that's term can apply standalone program.

the thread calls extension single-threaded apartment, can use thread.getapartmentstate() in code double-check. sta requirement thread displays ui, commonly in extension.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -