Mercurial > pub > ImplabNet
annotate Implab/Diagnostics/Extensions.cs @ 123:f4d6ea6969cc v2
async queue improvements
author | cin |
---|---|
date | Tue, 13 Jan 2015 01:42:38 +0300 |
parents | 2573b562e328 |
children | 04d4c92d0f28 |
rev | line source |
---|---|
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
109
diff
changeset
|
1 using System; |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
109
diff
changeset
|
2 |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
109
diff
changeset
|
3 namespace Implab.Diagnostics { |
92 | 4 public static class Extensions { |
5 public static IPromise<T> EndLogicalOperation<T>(this IPromise<T> promise) { | |
6 Safe.ArgumentNotNull(promise, "promise"); | |
7 var op = TraceContext.Instance.DetachLogicalOperation(); | |
8 | |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
109
diff
changeset
|
9 return promise.On( |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
109
diff
changeset
|
10 x => { |
109 | 11 TraceContext.Instance.EnterLogicalOperation(op,true); |
12 TraceLog.TraceInformation("promise = {0}", x); | |
13 TraceLog.EndLogicalOperation(); | |
14 TraceContext.Instance.Leave(); | |
15 }, | |
16 err =>{ | |
17 TraceContext.Instance.EnterLogicalOperation(op,true); | |
18 TraceLog.TraceError("promise died {0}", err); | |
19 TraceLog.EndLogicalOperation(); | |
20 TraceContext.Instance.Leave(); | |
21 }, | |
22 () => { | |
23 TraceContext.Instance.EnterLogicalOperation(op,true); | |
24 TraceLog.TraceInformation("promise cancelled"); | |
25 TraceLog.EndLogicalOperation(); | |
26 TraceContext.Instance.Leave(); | |
27 } | |
28 ); | |
92 | 29 } |
94 | 30 |
31 public static IPromise EndLogicalOperation(this IPromise promise) { | |
32 Safe.ArgumentNotNull(promise, "promise"); | |
33 var op = TraceContext.Instance.DetachLogicalOperation(); | |
34 | |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
109
diff
changeset
|
35 return promise.On(() => { |
94 | 36 TraceContext.Instance.EnterLogicalOperation(op,true); |
37 TraceLog.EndLogicalOperation(); | |
38 TraceContext.Instance.Leave(); | |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
109
diff
changeset
|
39 }, PromiseEventType.All); |
94 | 40 } |
92 | 41 } |
42 } | |
43 |