view MonoPlay/Program.cs @ 203:4d9830a9bbb8 v2

Added 'Fail' method to RunnableComponent which allows component to move from Running to Failed state. Added PollingComponent a timer based runnable component More tests Added FailPromise a thin class to wrap exceptions Fixed error handling in SuccessPromise classes.
author cin
date Tue, 18 Oct 2016 17:49:54 +0300
parents d7cd7a83189a
children
line wrap: on
line source

using Implab;
using Implab.Parallels;
using Implab.Diagnostics;
using System.Threading;

namespace MonoPlay {
    class MainClass {


        public static void Main(string[] args) {
            var pool = new WorkerPool(10);

            var listerner = new ConsoleTraceListener();
            listerner.Subscribe<TraceEvent>();

            TraceLog.StartLogicalOperation("Main");


            var d = pool.Invoke(() => {
                TraceLog.StartLogicalOperation("Worker");
                Thread.Sleep(100);
                TraceLog.TraceInformation("worker done");
                TraceLog.EndLogicalOperation();
            });

            var op = TraceContext.Instance.CurrentOperation;
            ThreadPool.QueueUserWorkItem((o) => {
                TraceContext.Instance.EnterLogicalOperation(op, false);
                TraceLog.StartLogicalOperation("Thread");
                Thread.Sleep(100);
                TraceLog.TraceInformation("thread done");
                TraceLog.EndLogicalOperation();
            });

            TraceLog.TraceInformation("main done");
            TraceLog.EndLogicalOperation();

            d.Join();



        }

    }
}