Program.cs
45 lines
| 1.2 KiB
| text/x-csharp
|
CSharpLexer
/ MonoPlay / Program.cs
cin
|
r201 | using Implab; | ||
cin
|
r194 | using Implab.Parallels; | ||
cin
|
r201 | using Implab.Diagnostics; | ||
cin
|
r194 | using System.Threading; | ||
cin
|
r93 | |||
namespace MonoPlay { | ||||
class MainClass { | ||||
cin
|
r145 | |||
cin
|
r93 | public static void Main(string[] args) { | ||
cin
|
r194 | var pool = new WorkerPool(10); | ||
cin
|
r150 | |||
cin
|
r194 | var listerner = new ConsoleTraceListener(); | ||
cin
|
r201 | listerner.Subscribe<TraceEvent>(); | ||
cin
|
r194 | |||
cin
|
r201 | TraceLog.StartLogicalOperation("Main"); | ||
cin
|
r93 | |||
cin
|
r194 | var d = pool.Invoke(() => { | ||
cin
|
r201 | TraceLog.StartLogicalOperation("Worker"); | ||
cin
|
r194 | Thread.Sleep(100); | ||
cin
|
r201 | TraceLog.TraceInformation("worker done"); | ||
TraceLog.EndLogicalOperation(); | ||||
cin
|
r194 | }); | ||
cin
|
r136 | |||
cin
|
r201 | var op = TraceContext.Instance.CurrentOperation; | ||
cin
|
r194 | ThreadPool.QueueUserWorkItem((o) => { | ||
cin
|
r201 | TraceContext.Instance.EnterLogicalOperation(op, false); | ||
TraceLog.StartLogicalOperation("Thread"); | ||||
cin
|
r194 | Thread.Sleep(100); | ||
cin
|
r201 | TraceLog.TraceInformation("thread done"); | ||
TraceLog.EndLogicalOperation(); | ||||
cin
|
r194 | }); | ||
cin
|
r150 | |||
cin
|
r201 | TraceLog.TraceInformation("main done"); | ||
TraceLog.EndLogicalOperation(); | ||||
cin
|
r194 | |||
d.Join(); | ||||
cin
|
r183 | |||
cin
|
r145 | } | ||
cin
|
r136 | |||
cin
|
r93 | } | ||
} | ||||