comparison Implab/Diagnostics/Extensions.cs @ 109:1b7ebcc52e5a v2

minor fixes
author cin
date Fri, 14 Nov 2014 14:04:24 +0300
parents a43745f81f10
children 2573b562e328
comparison
equal deleted inserted replaced
108:f3bdb7ba59b9 109:1b7ebcc52e5a
2 public static class Extensions { 2 public static class Extensions {
3 public static IPromise<T> EndLogicalOperation<T>(this IPromise<T> promise) { 3 public static IPromise<T> EndLogicalOperation<T>(this IPromise<T> promise) {
4 Safe.ArgumentNotNull(promise, "promise"); 4 Safe.ArgumentNotNull(promise, "promise");
5 var op = TraceContext.Instance.DetachLogicalOperation(); 5 var op = TraceContext.Instance.DetachLogicalOperation();
6 6
7 return promise.Anyway(() => { 7 return promise.Then<T>(
8 TraceContext.Instance.EnterLogicalOperation(op,true); 8 x => {
9 TraceLog.EndLogicalOperation(); 9 TraceContext.Instance.EnterLogicalOperation(op,true);
10 TraceContext.Instance.Leave(); 10 TraceLog.TraceInformation("promise = {0}", x);
11 }); 11 TraceLog.EndLogicalOperation();
12 TraceContext.Instance.Leave();
13 return x;
14 },
15 err =>{
16 TraceContext.Instance.EnterLogicalOperation(op,true);
17 TraceLog.TraceError("promise died {0}", err);
18 TraceLog.EndLogicalOperation();
19 TraceContext.Instance.Leave();
20 throw new TransientPromiseException(err);
21 },
22 () => {
23 TraceContext.Instance.EnterLogicalOperation(op,true);
24 TraceLog.TraceInformation("promise cancelled");
25 TraceLog.EndLogicalOperation();
26 TraceContext.Instance.Leave();
27 }
28 );
12 } 29 }
13 30
14 public static IPromise EndLogicalOperation(this IPromise promise) { 31 public static IPromise EndLogicalOperation(this IPromise promise) {
15 Safe.ArgumentNotNull(promise, "promise"); 32 Safe.ArgumentNotNull(promise, "promise");
16 var op = TraceContext.Instance.DetachLogicalOperation(); 33 var op = TraceContext.Instance.DetachLogicalOperation();