view MonoPlay/Program.cs @ 194:d45bdf510514 v2

working on diagnostics
author cin
date Mon, 25 Apr 2016 15:18:56 +0300
parents 4f82e0f161c3
children d7cd7a83189a
line wrap: on
line source

using System;
using Implab;
using System.Threading.Tasks;
using Implab.Formats.JSON;
using System.IO;
using System.Text.Json;
using System.Diagnostics;
using Implab.Parallels;
using System.Threading;

namespace MonoPlay {
    class MainClass {


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

            var listerner = new ConsoleTraceListener();
            listerner.TraceOutputOptions = TraceOptions.LogicalOperationStack;
            Trace.Listeners.Add(listerner);

            Trace.CorrelationManager.StartLogicalOperation("Main");

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

            ThreadPool.QueueUserWorkItem((o) => {
                Trace.CorrelationManager.StartLogicalOperation("Thread");
                Thread.Sleep(100);
                Trace.TraceInformation("thread done");
                Trace.CorrelationManager.StopLogicalOperation();
            });

            Trace.TraceInformation("main done");
            Trace.CorrelationManager.StopLogicalOperation();

            d.Join();



        }

    }
}