+
+ static bool IsSTAThread {
+ get {
+ bool isSTA = Thread.CurrentThread.ApartmentState ==
+ ApartmentState.STA;
+
+ // FIXME: remove this check after Thread.ApartmentState
+ // has been properly implemented.
+ if (!isSTA) {
+ Assembly asm = Assembly.GetEntryAssembly ();
+ if (asm != null)
+ isSTA = asm.EntryPoint.GetCustomAttributes (typeof (STAThreadAttribute), false).Length > 0;
+ }
+
+ return isSTA;
+ }
+ }