comparison Implab/PromiseExtensions.cs @ 109:1b7ebcc52e5a v2

minor fixes
author cin
date Fri, 14 Nov 2014 14:04:24 +0300
parents 5f10d54b45df
children 1a8426e6e895
comparison
equal deleted inserted replaced
108:f3bdb7ba59b9 109:1b7ebcc52e5a
1 using System.Threading; 1 using System.Threading;
2 using System; 2 using System;
3 using Implab.Diagnostics;
4
5
3 #if NET_4_5 6 #if NET_4_5
4 using System.Threading.Tasks; 7 using System.Threading.Tasks;
5 #endif 8 #endif
6 9
7 namespace Implab { 10 namespace Implab {
55 } 58 }
56 59
57 public static AsyncCallback AsyncCallback<T>(this Promise<T> that, Func<IAsyncResult,T> callback) { 60 public static AsyncCallback AsyncCallback<T>(this Promise<T> that, Func<IAsyncResult,T> callback) {
58 Safe.ArgumentNotNull(that, "that"); 61 Safe.ArgumentNotNull(that, "that");
59 Safe.ArgumentNotNull(callback, "callback"); 62 Safe.ArgumentNotNull(callback, "callback");
63 var op = TraceContext.Instance.CurrentOperation;
60 return ar => { 64 return ar => {
65 TraceContext.Instance.EnterLogicalOperation(op,false);
61 try { 66 try {
62 that.Resolve(callback(ar)); 67 that.Resolve(callback(ar));
63 } catch (Exception err) { 68 } catch (Exception err) {
64 that.Reject(err); 69 that.Reject(err);
70 } finally {
71 TraceContext.Instance.Leave();
65 } 72 }
66 }; 73 };
67 } 74 }
68 75
69 #if NET_4_5 76 #if NET_4_5