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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
d6fe09f5592c Improved AsyncQueue
cin
parents: 229
diff changeset
3 using Implab.Parallels;
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
4 using Implab.Xml;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
5 using System;
233
d6fe09f5592c Improved AsyncQueue
cin
parents: 229
diff changeset
6 using System.Collections.Concurrent;
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
7 using System.Collections.Generic;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
8 using System.IO;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
9 using System.Linq;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
10 using System.Text;
233
d6fe09f5592c Improved AsyncQueue
cin
parents: 229
diff changeset
11 using System.Threading;
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
12 using System.Threading.Tasks;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
13 using System.Xml;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
14 using System.Xml.Serialization;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
15
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
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
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
21 public class Program {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
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
d6fe09f5592c Improved AsyncQueue
cin
parents: 229
diff changeset
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
d6fe09f5592c Improved AsyncQueue
cin
parents: 229
diff changeset
32
255
b00441e04738 Adde workaround to the behaviour of the logical operations stack in conjuction
cin
parents: 236
diff changeset
33 Main().Wait();
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
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
d6fe09f5592c Improved AsyncQueue
cin
parents: 229
diff changeset
37 }
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
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
d6fe09f5592c Improved AsyncQueue
cin
parents: 229
diff changeset
45 }
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
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
d6fe09f5592c Improved AsyncQueue
cin
parents: 229
diff changeset
52 }
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
53 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
54 }
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents:
diff changeset
55 }