Mercurial > pub > ImplabNet
comparison Implab/Diagnostics/Extensions.cs @ 192:f1da3afc3521 release v2.1
Слияние с v2
author | cin |
---|---|
date | Fri, 22 Apr 2016 13:10:34 +0300 |
parents | f973c5df9972 |
children |
comparison
equal
deleted
inserted
replaced
71:1714fd8678ef | 192:f1da3afc3521 |
---|---|
1 namespace Implab.Diagnostics { | |
2 public static class Extensions { | |
3 public static IPromise<T> EndLogicalOperation<T>(this IPromise<T> promise) { | |
4 Safe.ArgumentNotNull(promise, "promise"); | |
5 var op = TraceContext.Instance.DetachLogicalOperation(); | |
6 | |
7 return promise.On( | |
8 x => { | |
9 TraceContext.Instance.EnterLogicalOperation(op,true); | |
10 TraceLog.TraceInformation("promise = {0}", x); | |
11 TraceLog.EndLogicalOperation(); | |
12 TraceContext.Instance.Leave(); | |
13 }, | |
14 err =>{ | |
15 TraceContext.Instance.EnterLogicalOperation(op,true); | |
16 TraceLog.TraceError("promise died {0}", err); | |
17 TraceLog.EndLogicalOperation(); | |
18 TraceContext.Instance.Leave(); | |
19 }, | |
20 reason => { | |
21 TraceContext.Instance.EnterLogicalOperation(op,true); | |
22 TraceLog.TraceInformation("promise cancelled {0}", reason == null ? "<no-reason>" : reason.Message); | |
23 TraceLog.EndLogicalOperation(); | |
24 TraceContext.Instance.Leave(); | |
25 } | |
26 ); | |
27 } | |
28 | |
29 public static IPromise EndLogicalOperation(this IPromise promise) { | |
30 Safe.ArgumentNotNull(promise, "promise"); | |
31 var op = TraceContext.Instance.DetachLogicalOperation(); | |
32 | |
33 return promise.On(() => { | |
34 TraceContext.Instance.EnterLogicalOperation(op,true); | |
35 TraceLog.EndLogicalOperation(); | |
36 TraceContext.Instance.Leave(); | |
37 }, PromiseEventType.All); | |
38 } | |
39 } | |
40 } | |
41 |