Mercurial > pub > ImplabNet
annotate MonoPlay/Program.cs @ 162:0526412bbb26 ref20160224
DFA refactoring
author | cin |
---|---|
date | Wed, 24 Feb 2016 08:39:53 +0300 |
parents | 97fbbf816844 |
children | 4f82e0f161c3 |
rev | line source |
---|---|
93 | 1 using System; |
2 using Implab; | |
151 | 3 using System.Threading.Tasks; |
93 | 4 |
5 namespace MonoPlay { | |
6 class MainClass { | |
145 | 7 |
8 | |
93 | 9 public static void Main(string[] args) { |
94 | 10 if (args == null) |
11 throw new ArgumentNullException("args"); | |
12 | |
103 | 13 var t1 = Environment.TickCount; |
93 | 14 |
151 | 15 DoWork().GetAwaiter().GetResult(); |
150 | 16 |
103 | 17 var t2 = Environment.TickCount; |
125 | 18 Console.WriteLine("done: {0} ms, {1:.00} Mb, {2} GC", t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0) ); |
93 | 19 |
20 } | |
136 | 21 |
151 | 22 static IPromise<int> DoItem(int x) { |
156
97fbbf816844
Promises: SignalXXX methods merged into SignalHandler method.
cin
parents:
151
diff
changeset
|
23 //return Promise<int>.FromResult(x + 1); |
97fbbf816844
Promises: SignalXXX methods merged into SignalHandler method.
cin
parents:
151
diff
changeset
|
24 var p = new Promise<int>(); |
97fbbf816844
Promises: SignalXXX methods merged into SignalHandler method.
cin
parents:
151
diff
changeset
|
25 p.Resolve(x+1); |
97fbbf816844
Promises: SignalXXX methods merged into SignalHandler method.
cin
parents:
151
diff
changeset
|
26 return p; |
151 | 27 } |
150 | 28 |
151 | 29 static async Task<int> DoWork() { |
30 var c = 0; | |
31 for (int i = 0; i < 10000000; i++) | |
32 c = await DoItem(c); | |
33 return c; | |
145 | 34 } |
136 | 35 |
93 | 36 } |
37 } |