Author: robertj
Date: 2006-11-07 16:13:05 -0500 (Tue, 07 Nov 2006)
New Revision: 67496
Modified:
trunk/mcs/class/corlib/System.Threading/ChangeLog
trunk/mcs/class/corlib/System.Threading/WaitHandle.cs
Log:
2006-11-07 Robert Jordan <[EMAIL PROTECTED]>
* WaitHandle.cs: Don't assume Assembly.GetEntryAssembly () != null.
Fixes bug #79859.
Modified: trunk/mcs/class/corlib/System.Threading/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Threading/ChangeLog 2006-11-07 21:08:07 UTC
(rev 67495)
+++ trunk/mcs/class/corlib/System.Threading/ChangeLog 2006-11-07 21:13:05 UTC
(rev 67496)
@@ -1,3 +1,8 @@
+2006-11-07 Robert Jordan <[EMAIL PROTECTED]>
+
+ * WaitHandle.cs: Don't assume Assembly.GetEntryAssembly () != null.
+ Fixes bug #79859.
+
2006-11-02 Dick Porter <[EMAIL PROTECTED]>
* Thread.cs: Use the new Interrupt and SpinWait icalls.
Modified: trunk/mcs/class/corlib/System.Threading/WaitHandle.cs
===================================================================
--- trunk/mcs/class/corlib/System.Threading/WaitHandle.cs 2006-11-07
21:08:07 UTC (rev 67495)
+++ trunk/mcs/class/corlib/System.Threading/WaitHandle.cs 2006-11-07
21:13:05 UTC (rev 67496)
@@ -50,9 +50,7 @@
if (length > 64)
throw new NotSupportedException ("Too many
handles");
- if (waitAll && length > 1 &&
- (Thread.CurrentThread.ApartmentState ==
ApartmentState.STA ||
- Assembly.GetEntryAssembly
().EntryPoint.GetCustomAttributes (typeof (STAThreadAttribute), false).Length
== 1))
+ if (waitAll && length > 1 && IsSTAThread)
throw new NotSupportedException ("WaitAll for
multiple handles is not allowed on an STA thread.");
foreach (WaitHandle w in handles) {
@@ -63,6 +61,23 @@
throw new ArgumentException ("null
element found", "waitHandle");
}
}
+
+ 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;
+ }
+ }
public static bool WaitAll(WaitHandle[] waitHandles)
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches