@@ -26,7 +26,7 namespace Implab.Diagnostics { | |||||
26 | msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, channel, text.content); |
|
26 | msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, channel, text.content); | |
27 |
|
27 | |||
28 | lock (_consoleLock) { |
|
28 | lock (_consoleLock) { | |
29 | Console.ForegroundColor = (ConsoleColor)(args.ThreadId % 15 + 1); |
|
29 | //Console.ForegroundColor = (ConsoleColor)(args.ThreadId % 15 + 1); | |
30 | Console.WriteLine(msg); |
|
30 | Console.WriteLine(msg); | |
31 | } |
|
31 | } | |
32 | } |
|
32 | } |
@@ -4,11 +4,28 | |||||
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. |
|
7 | return promise.Then<T>( | |
8 | TraceContext.Instance.EnterLogicalOperation(op,true); |
|
8 | x => { | |
9 |
|
|
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) { |
@@ -1,5 +1,8 | |||||
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 | |
@@ -57,11 +60,15 namespace Implab { | |||||
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 | } |
General Comments 0
You need to be logged in to leave comments.
Login now