Mercurial > pub > ImplabNet
view Implab/Diagnostics/Extensions.cs @ 120:f1b897999260 v2
improved asyncpool usability
working on batch operations on asyncqueue
author | cin |
---|---|
date | Mon, 12 Jan 2015 05:19:52 +0300 |
parents | 2573b562e328 |
children | 04d4c92d0f28 |
line wrap: on
line source
using System; 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); } } }