Extensions.cs
41 lines
| 1.7 KiB
| text/x-csharp
|
CSharpLexer
cin
|
r134 | namespace Implab.Diagnostics { | ||
cin
|
r92 | public static class Extensions { | ||
public static IPromise<T> EndLogicalOperation<T>(this IPromise<T> promise) { | ||||
Safe.ArgumentNotNull(promise, "promise"); | ||||
var op = TraceContext.Instance.DetachLogicalOperation(); | ||||
cin
|
r119 | return promise.On( | ||
x => { | ||||
cin
|
r109 | TraceContext.Instance.EnterLogicalOperation(op,true); | ||
TraceLog.TraceInformation("promise = {0}", x); | ||||
TraceLog.EndLogicalOperation(); | ||||
TraceContext.Instance.Leave(); | ||||
}, | ||||
err =>{ | ||||
TraceContext.Instance.EnterLogicalOperation(op,true); | ||||
TraceLog.TraceError("promise died {0}", err); | ||||
TraceLog.EndLogicalOperation(); | ||||
TraceContext.Instance.Leave(); | ||||
}, | ||||
cin
|
r138 | reason => { | ||
cin
|
r109 | TraceContext.Instance.EnterLogicalOperation(op,true); | ||
cin
|
r140 | TraceLog.TraceInformation("promise cancelled {0}", reason == null ? "<no-reason>" : reason.Message); | ||
cin
|
r109 | TraceLog.EndLogicalOperation(); | ||
TraceContext.Instance.Leave(); | ||||
} | ||||
); | ||||
cin
|
r92 | } | ||
cin
|
r94 | |||
public static IPromise EndLogicalOperation(this IPromise promise) { | ||||
Safe.ArgumentNotNull(promise, "promise"); | ||||
var op = TraceContext.Instance.DetachLogicalOperation(); | ||||
cin
|
r119 | return promise.On(() => { | ||
cin
|
r94 | TraceContext.Instance.EnterLogicalOperation(op,true); | ||
TraceLog.EndLogicalOperation(); | ||||
TraceContext.Instance.Leave(); | ||||
cin
|
r119 | }, PromiseEventType.All); | ||
cin
|
r94 | } | ||
cin
|
r92 | } | ||
} | ||||