فهرست منبع

2007-09-25 Jonathan Pobst <[email protected]>

	* SynchronizationContext.cs: Implement SetSynchronizationContext.

2007-09-25  Jonathan Pobst  <[email protected]>

	* AsyncOperationManager.cs: Tie the SynchronizationContext here to
	SynchronizationContext.Current.

2007-09-25  Jonathan Pobst  <[email protected]>

	* AsyncOperationManagerTest.cs: Add test for SynchronizationContext.

2007-09-25  Jonathan Pobst  <[email protected]>

	* System_test.dll.sources: Added AsyncOperationManagerTest.cs.

svn path=/trunk/mcs/; revision=86329
Jonathan Pobst 18 سال پیش
والد
کامیت
7dc885163c

+ 4 - 0
mcs/class/System/ChangeLog

@@ -1,3 +1,7 @@
+2007-09-25  Jonathan Pobst  <[email protected]>
+
+	* System_test.dll.sources: Added AsyncOperationManagerTest.cs.
+
 2007-09-17  Gert Driesen  <[email protected]>
 
 	* System_test.dll.sources: Added ComponentResourceManagerTest.cs.

+ 8 - 8
mcs/class/System/System.ComponentModel/AsyncOperationManager.cs

@@ -35,26 +35,26 @@ namespace System.ComponentModel
 {
 	public static class AsyncOperationManager
 	{
-		static readonly SynchronizationContext default_context;
-		static SynchronizationContext current_context;
-
 		static AsyncOperationManager ()
 		{
-			default_context = new SynchronizationContext ();
-			current_context = default_context;
 		}
 
 		[EditorBrowsable (EditorBrowsableState.Advanced)]
 		public static SynchronizationContext SynchronizationContext {
-			get { return current_context; }
+			get { 
+				if (SynchronizationContext.Current == null)
+					SynchronizationContext.SetSynchronizationContext (new SynchronizationContext ());
+				
+				return SynchronizationContext.Current;
+			}
 			[SecurityPermission (SecurityAction.LinkDemand)]
-			set { current_context = value != null ? value : default_context; }
+			set { SynchronizationContext.SetSynchronizationContext (value); }
 		}
 
 		public static AsyncOperation CreateOperation (object userSuppliedState)
 		{
 			return new AsyncOperation (
-				current_context, userSuppliedState);
+				SynchronizationContext, userSuppliedState);
 		}
 	}
 }

+ 5 - 0
mcs/class/System/System.ComponentModel/ChangeLog

@@ -1,3 +1,8 @@
+2007-09-25  Jonathan Pobst  <[email protected]>
+
+	* AsyncOperationManager.cs: Tie the SynchronizationContext here to
+	SynchronizationContext.Current.
+
 2007-09-17  Gert Driesen  <[email protected]>
 
 	* ComponentResourceManager.cs: In ApplyResources, when culture is

+ 1 - 0
mcs/class/System/System_test.dll.sources

@@ -107,6 +107,7 @@ System.Collections.Specialized/OrderedDictionaryTest.cs
 System.Collections.Specialized/StringCollectionTest.cs
 System.Collections.Specialized/StringDictionaryTest.cs
 System.ComponentModel/ArrayConverterTests.cs
+System.ComponentModel/AsyncOperationManagerTest.cs
 System.ComponentModel/AttributeProviderAttributeTest.cs
 System.ComponentModel/BackgroundWorkerTest.cs
 System.ComponentModel/BindingListTest.cs

+ 61 - 0
mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs

@@ -0,0 +1,61 @@
+//
+// AsyncOperationManager.cs
+//
+// Author:
+// 	Jonathan Pobst  <[email protected]>
+//
+// Copyright (C) 2007 Novell, Inc.
+//
+
+#if NET_2_0
+
+using System;
+using System.Threading;
+using System.ComponentModel;
+using System.Globalization;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ComponentModel
+{
+	[TestFixture]
+	public class AsyncOperationManagerTest
+	{
+		[Test]
+		public void SyncContext ()
+		{
+			SynchronizationContext sc1 = new SynchronizationContext ();
+			SynchronizationContext sc2 = new SynchronizationContext ();
+
+			Assert.IsNull (SynchronizationContext.Current, "A1");
+			Assert.IsNotNull (AsyncOperationManager.SynchronizationContext, "A2");
+			Assert.IsNotNull (SynchronizationContext.Current, "A3");
+			
+			SynchronizationContext.SetSynchronizationContext (sc1);
+
+			Assert.AreSame (sc1, SynchronizationContext.Current, "A4");
+			Assert.AreSame (sc1, AsyncOperationManager.SynchronizationContext, "A5");
+			
+			AsyncOperationManager.SynchronizationContext = sc2;
+
+			Assert.AreSame (sc2, SynchronizationContext.Current, "A6");
+			Assert.AreSame (sc2, AsyncOperationManager.SynchronizationContext, "A7");
+			
+			SynchronizationContext.SetSynchronizationContext (null);
+
+			Assert.IsNull (SynchronizationContext.Current, "A8");
+			// This is a brand new one, not sc1 or sc2
+			Assert.IsNotNull (AsyncOperationManager.SynchronizationContext, "A9");
+			Assert.IsNotNull (SynchronizationContext.Current, "A10");
+			
+			AsyncOperationManager.SynchronizationContext = null;
+
+			Assert.IsNull (SynchronizationContext.Current, "A11");
+			// This is a brand new one, not sc1 or sc2
+			Assert.IsNotNull (AsyncOperationManager.SynchronizationContext, "A12");
+			Assert.IsNotNull (SynchronizationContext.Current, "A13");
+		}
+	}
+}
+
+#endif

+ 4 - 0
mcs/class/System/Test/System.ComponentModel/ChangeLog

@@ -1,3 +1,7 @@
+2007-09-25  Jonathan Pobst  <[email protected]>
+
+	* AsyncOperationManagerTest.cs: Add test for SynchronizationContext.
+
 2007-09-17  Gert Driesen  <[email protected]>
 
 	* ComponentResourceManagerTest.cs: Added tests for ctors,

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

@@ -1,3 +1,7 @@
+2007-09-25  Jonathan Pobst  <[email protected]>
+
+	* SynchronizationContext.cs: Implement SetSynchronizationContext.
+
 2007-09-06  Dick Porter  <[email protected]>
 
 	* Timer.cs: Only hold a WeakReference to the runner thread, to

+ 1 - 2
mcs/class/corlib/System.Threading/SynchronizationContext.cs

@@ -88,10 +88,9 @@ namespace System.Threading
 			Send (d, state);
 		}
 		
-		[MonoTODO]
 		public static void SetSynchronizationContext (SynchronizationContext syncContext)
 		{
-			throw new NotImplementedException ();
+			currentContext = syncContext;
 		}
 
 		[MonoTODO]