##// END OF EJS Templates
minor fixes
cin -
r109:1b7ebcc52e5a v2
parent child
Show More
@@ -26,7 +26,7 namespace Implab.Diagnostics {
26 26 msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, channel, text.content);
27 27
28 28 lock (_consoleLock) {
29 Console.ForegroundColor = (ConsoleColor)(args.ThreadId % 15 + 1);
29 //Console.ForegroundColor = (ConsoleColor)(args.ThreadId % 15 + 1);
30 30 Console.WriteLine(msg);
31 31 }
32 32 }
@@ -4,11 +4,28
4 4 Safe.ArgumentNotNull(promise, "promise");
5 5 var op = TraceContext.Instance.DetachLogicalOperation();
6 6
7 return promise.Anyway(() => {
7 return promise.Then<T>(
8 x => {
8 9 TraceContext.Instance.EnterLogicalOperation(op,true);
10 TraceLog.TraceInformation("promise = {0}", x);
9 11 TraceLog.EndLogicalOperation();
10 12 TraceContext.Instance.Leave();
11 });
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 31 public static IPromise EndLogicalOperation(this IPromise promise) {
@@ -1,5 +1,8
1 1 using System.Threading;
2 2 using System;
3 using Implab.Diagnostics;
4
5
3 6 #if NET_4_5
4 7 using System.Threading.Tasks;
5 8 #endif
@@ -57,11 +60,15 namespace Implab {
57 60 public static AsyncCallback AsyncCallback<T>(this Promise<T> that, Func<IAsyncResult,T> callback) {
58 61 Safe.ArgumentNotNull(that, "that");
59 62 Safe.ArgumentNotNull(callback, "callback");
63 var op = TraceContext.Instance.CurrentOperation;
60 64 return ar => {
65 TraceContext.Instance.EnterLogicalOperation(op,false);
61 66 try {
62 67 that.Resolve(callback(ar));
63 68 } catch (Exception err) {
64 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