Author: kostat
Date: 2006-12-20 08:33:07 -0500 (Wed, 20 Dec 2006)
New Revision: 69809

Modified:
   trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs
Log:
Run all the WebTests in one and only one TreadPool thread

Modified: trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs        
2006-12-20 12:08:47 UTC (rev 69808)
+++ trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs        
2006-12-20 13:33:07 UTC (rev 69809)
@@ -12,12 +12,17 @@
 using System.Reflection;
 using System.Threading;
 using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters.Binary;
+using System.Runtime.Serialization.Formatters.Binary;
 
 namespace MonoTests.SystemWeb.Framework
 {
        internal class MyHost : MarshalByRefObject
        {
+               AutoResetEvent _done;
+               AutoResetEvent _doNext;
+               WebTest _currentTest;
+               Exception _e;
+
                #region MyData
                class MyData
                {
@@ -26,11 +31,35 @@
                }
                #endregion
                
+               public MyHost ()
+               {
+                       _done = new AutoResetEvent (false);
+                       _doNext = new AutoResetEvent (false);
+                       ThreadPool.QueueUserWorkItem (new WaitCallback 
(AsyncRun), null);
+               }
+
                public AppDomain AppDomain
                { get { return AppDomain.CurrentDomain; } }
-               
-               public WebTest Run (WebTest t)
+               
+               public WebTest Run (WebTest t)
                {
+                       _currentTest = t;
+                       _doNext.Set ();
+                       _done.WaitOne ();
+                       if (_e != null) {
+                               Exception e = _e;
+                               _e = null;
+                               throw e;
+                       }
+                       return t;
+               }
+
+               void AsyncRun (object param)
+               {
+                       for (;;) {
+                       _doNext.WaitOne ();
+                       try {
+                       WebTest t = _currentTest;
                        HttpWorkerRequest wr = t.Request.CreateWorkerRequest ();
                        MyData data = GetMyData (wr);
                        data.currentTest = t;
@@ -41,8 +70,12 @@
                        
                        if (data.exception != null)
                                RethrowException (data.exception);
+                       } catch (Exception e) {
+                               _e = e;
+                       }
 
-                       return t;
+                       _done.Set ();
+                       }
                }
 
                private static void RethrowException (Exception inner)

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

Reply via email to