Changed AsyncManualResetEvent.Set behaviour to occur asynchronously. In the previous...
authorPanagiotis Kanavos <pkanavos@gmail.com>
Fri, 17 Feb 2012 15:02:19 +0000 (17:02 +0200)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Fri, 17 Feb 2012 15:02:19 +0000 (17:02 +0200)
trunk/Pithos.Core/Agents/AsyncManualResetEvent.cs
trunk/Pithos.Core/Agents/NetworkAgent.cs

index 00ec851..c0e621f 100644 (file)
@@ -39,7 +39,13 @@ namespace Pithos.Core.Agents
             _tcs.Task.Wait();\r
         }\r
 \r
-        public void Set() { _tcs.TrySetResult(true); }\r
+        public void Set()\r
+        {\r
+            var tcs = _tcs;\r
+            Task.Factory.StartNew(s => ((TaskCompletionSource<bool>)s).TrySetResult(true),\r
+                tcs, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default);\r
+            tcs.Task.Wait(); \r
+        }\r
 \r
         public void Reset()\r
         {\r
index 72ae3c5..93bbcfc 100644 (file)
@@ -343,6 +343,8 @@ namespace Pithos.Core.Agents
         //Remote files are polled periodically. Any changes are processed
         public async Task PollRemoteFiles(DateTime? since = null)
         {
+            Debug.Assert(Thread.CurrentThread.IsBackground,"Polling Ended up in the main thread!");
+
             UpdateStatus(PithosStatus.Syncing);
             StatusNotification.Notify(new PollNotification());