Author: jpobst
Date: 2007-09-25 10:38:37 -0400 (Tue, 25 Sep 2007)
New Revision: 86329

Added:
   
trunk/mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs
Modified:
   trunk/mcs/class/System/ChangeLog
   trunk/mcs/class/System/System.ComponentModel/AsyncOperationManager.cs
   trunk/mcs/class/System/System.ComponentModel/ChangeLog
   trunk/mcs/class/System/System_test.dll.sources
   trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
   trunk/mcs/class/corlib/System.Threading/ChangeLog
   trunk/mcs/class/corlib/System.Threading/SynchronizationContext.cs
Log:
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.

Modified: trunk/mcs/class/System/ChangeLog
===================================================================
--- trunk/mcs/class/System/ChangeLog    2007-09-25 14:36:32 UTC (rev 86328)
+++ trunk/mcs/class/System/ChangeLog    2007-09-25 14:38:37 UTC (rev 86329)
@@ -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.

Modified: trunk/mcs/class/System/System.ComponentModel/AsyncOperationManager.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/AsyncOperationManager.cs       
2007-09-25 14:36:32 UTC (rev 86328)
+++ trunk/mcs/class/System/System.ComponentModel/AsyncOperationManager.cs       
2007-09-25 14:38:37 UTC (rev 86329)
@@ -35,26 +35,26 @@
 {
        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);
                }
        }
 }

Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog      2007-09-25 
14:36:32 UTC (rev 86328)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog      2007-09-25 
14:38:37 UTC (rev 86329)
@@ -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

Modified: trunk/mcs/class/System/System_test.dll.sources
===================================================================
--- trunk/mcs/class/System/System_test.dll.sources      2007-09-25 14:36:32 UTC 
(rev 86328)
+++ trunk/mcs/class/System/System_test.dll.sources      2007-09-25 14:38:37 UTC 
(rev 86329)
@@ -107,6 +107,7 @@
 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

Added: 
trunk/mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs
===================================================================
--- 
trunk/mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs  
    2007-09-25 14:36:32 UTC (rev 86328)
+++ 
trunk/mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs  
    2007-09-25 14:38:37 UTC (rev 86329)
@@ -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

Modified: trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2007-09-25 
14:36:32 UTC (rev 86328)
+++ trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2007-09-25 
14:38:37 UTC (rev 86329)
@@ -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,

Modified: trunk/mcs/class/corlib/System.Threading/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Threading/ChangeLog   2007-09-25 14:36:32 UTC 
(rev 86328)
+++ trunk/mcs/class/corlib/System.Threading/ChangeLog   2007-09-25 14:38:37 UTC 
(rev 86329)
@@ -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

Modified: trunk/mcs/class/corlib/System.Threading/SynchronizationContext.cs
===================================================================
--- trunk/mcs/class/corlib/System.Threading/SynchronizationContext.cs   
2007-09-25 14:36:32 UTC (rev 86328)
+++ trunk/mcs/class/corlib/System.Threading/SynchronizationContext.cs   
2007-09-25 14:38:37 UTC (rev 86329)
@@ -88,10 +88,9 @@
                        Send (d, state);
                }
                
-               [MonoTODO]
                public static void SetSynchronizationContext 
(SynchronizationContext syncContext)
                {
-                       throw new NotImplementedException ();
+                       currentContext = syncContext;
                }
 
                [MonoTODO]

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to