Mercurial > pub > ImplabNet
annotate Implab.Playground/Program.cs @ 255:b00441e04738 v3
Adde workaround to the behaviour of the logical operations stack in conjuction
with async/await methods
| author | cin |
|---|---|
| date | Wed, 04 Apr 2018 15:38:48 +0300 |
| parents | 302ca905c19e |
| children | 547a2fc0d93e |
| rev | line source |
|---|---|
|
255
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
1 using Implab.Diagnostics; |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
2 using Implab.Formats.Json; |
| 233 | 3 using Implab.Parallels; |
| 229 | 4 using Implab.Xml; |
| 5 using System; | |
| 233 | 6 using System.Collections.Concurrent; |
| 229 | 7 using System.Collections.Generic; |
| 8 using System.IO; | |
| 9 using System.Linq; | |
| 10 using System.Text; | |
| 233 | 11 using System.Threading; |
| 229 | 12 using System.Threading.Tasks; |
| 13 using System.Xml; | |
| 14 using System.Xml.Serialization; | |
| 15 | |
| 16 namespace Implab.Playground { | |
|
255
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
17 using System.Diagnostics; |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
18 using System.Runtime.Remoting.Messaging; |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
19 using static Trace<Program>; |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
20 |
| 229 | 21 public class Program { |
| 22 | |
|
255
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
23 static void Main(string[] args) { |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
24 var listener = new SimpleTraceListener(Console.Out); |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
25 |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
26 var source = Trace<Program>.TraceSource; |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
27 source.Switch.Level = SourceLevels.All; |
| 233 | 28 |
|
255
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
29 source.Listeners.Add(listener); |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
30 |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
31 var t = Environment.TickCount; |
| 233 | 32 |
|
255
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
33 Main().Wait(); |
| 229 | 34 |
|
255
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
35 Console.WriteLine($"Done: {Environment.TickCount - t} ms"); |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
36 Console.ReadKey(); |
| 233 | 37 } |
| 229 | 38 |
|
255
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
39 static async Task Main() { |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
40 using (LogicalOperation(nameof(Main))) { |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
41 Log("Start"); |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
42 await SomeAsync(); |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
43 Log("End"); |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
44 } |
| 233 | 45 } |
| 229 | 46 |
|
255
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
47 static async Task SomeAsync() { |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
48 using (LogicalOperation(nameof(SomeAsync))) { |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
49 Log("Do prepare"); |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
50 await Task.Yield(); |
|
b00441e04738
Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents:
236
diff
changeset
|
51 Log("Yield"); |
| 233 | 52 } |
| 229 | 53 } |
| 54 } | |
| 55 } |
