Logging changes, first changes to multi account support
[pithos-ms-client] / trunk / Pithos.Core / JobQueue.cs
index 78aa206..cca4a07 100644 (file)
@@ -48,5 +48,35 @@ namespace Pithos.Core
             _statusUpdateQueue.CompleteAdding();
         }
        
+    }   
+
+    public class JobAgent:Agent<Action>
+    {
+        protected JobAgent(Action<Agent<Action>>  action)
+            :base(action)
+        {
+            
+        }
+
+        public static JobAgent Create()
+        {
+            return (JobAgent)Start(queue =>
+            {
+                Action loop = null;
+                loop = () =>
+                {
+                    var job = queue.Receive();
+                    job.ContinueWith(t =>
+                    {
+                        t.IgnoreExceptions();
+                        var action = job.Result;
+                        action();
+                        queue.DoAsync(loop);
+                    });
+                };
+                loop();
+            });
+        }
+
     }
 }