Browse Source

2006-06-29 Duncan Mak <[email protected]>

	* WaitHandle.cs (CheckArray): Throw NotSupportedException if the
	current thread is marked with the STAThreadAttribute. Fixes bug
	#78455.

svn path=/trunk/mcs/; revision=62144
Duncan Mak 19 năm trước cách đây
mục cha
commit
13fd2ec3e5

+ 6 - 0
mcs/class/corlib/System.Threading/ChangeLog

@@ -1,3 +1,9 @@
+2006-06-29  Duncan Mak  <[email protected]>
+
+	* WaitHandle.cs (CheckArray): Throw NotSupportedException if the
+	current thread is marked with the STAThreadAttribute. Fixes bug
+	#78455.
+
 2006-05-05  Sebastien Pouliot  <[email protected]>
 
 	* ExecutionContext.cs: Don't capture the compressed stack unless the 

+ 8 - 0
mcs/class/corlib/System.Threading/WaitHandle.cs

@@ -28,6 +28,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System;
+using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Runtime.Remoting.Contexts;
 using System.Security.Permissions;
@@ -48,6 +50,12 @@ namespace System.Threading
 			if (length > 64)
 				throw new NotSupportedException ("Too many handles");
 
+			MethodInfo entryPoint = Assembly.GetEntryAssembly ().EntryPoint;
+			if (length > 1 &&
+			    (Thread.CurrentThread.ApartmentState == ApartmentState.STA ||
+			     entryPoint.GetCustomAttributes (typeof (STAThreadAttribute), false).Length == 1))
+				throw new NotSupportedException ("WaitAll for multiple handles is not allowed on an STA thread.");
+			
 			foreach (WaitHandle w in handles) {
 				if (w == null)
 					throw new ArgumentNullException ("waitHandles", "null handle");