##// END OF EJS Templates
shared locks + tests
shared locks + tests

File last commit:

r134:04d4c92d0f28 v2
r136:e9e7940c7d98 v2
Show More
Extensions.cs
41 lines | 1.6 KiB | text/x-csharp | CSharpLexer
namespace Implab.Diagnostics {
public static class Extensions {
public static IPromise<T> EndLogicalOperation<T>(this IPromise<T> promise) {
Safe.ArgumentNotNull(promise, "promise");
var op = TraceContext.Instance.DetachLogicalOperation();
return promise.On(
x => {
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();
},
() => {
TraceContext.Instance.EnterLogicalOperation(op,true);
TraceLog.TraceInformation("promise cancelled");
TraceLog.EndLogicalOperation();
TraceContext.Instance.Leave();
}
);
}
public static IPromise EndLogicalOperation(this IPromise promise) {
Safe.ArgumentNotNull(promise, "promise");
var op = TraceContext.Instance.DetachLogicalOperation();
return promise.On(() => {
TraceContext.Instance.EnterLogicalOperation(op,true);
TraceLog.EndLogicalOperation();
TraceContext.Instance.Leave();
}, PromiseEventType.All);
}
}
}