@@ -23,10 +23,10 namespace Implab.Diagnostics { | |||
|
23 | 23 | |
|
24 | 24 | for (int i = 0; i < text.indent; i++) |
|
25 | 25 | msg.Append(" "); |
|
26 |
msg.AppendFormat("[{0}]: |
|
|
26 | msg.AppendFormat("[{0}]: {1}", args.ThreadId, text.content); | |
|
27 | 27 | |
|
28 | 28 | lock (_consoleLock) { |
|
29 |
|
|
|
29 | Console.ForegroundColor = (ConsoleColor)(args.ThreadId % 15 + 1); | |
|
30 | 30 | Console.WriteLine(msg); |
|
31 | 31 | } |
|
32 | 32 | } |
@@ -41,10 +41,10 namespace Implab.Diagnostics { | |||
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | public void EnterLogicalOperation(LogicalOperation operation, bool takeOwnership) { |
|
44 | var prev = CurrentOperation; | |
|
44 | //var prev = CurrentOperation; | |
|
45 | 45 | m_stack.Push(m_current); |
|
46 | 46 | m_current = new OperationContext(operation, takeOwnership); |
|
47 | LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(takeOwnership ? TraceEventType.Attach : TraceEventType.Enter, String.Format("{0} -> {1}",prev.Name, operation.Name))); | |
|
47 | //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(takeOwnership ? TraceEventType.Attach : TraceEventType.Enter, String.Format("{0} -> {1}",prev.Name, operation.Name))); | |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | 50 | public void StartLogicalOperation(string name) { |
@@ -63,16 +63,16 namespace Implab.Diagnostics { | |||
|
63 | 63 | |
|
64 | 64 | public LogicalOperation DetachLogicalOperation() { |
|
65 | 65 | var prev = m_current.DetachLogicalOperation(); |
|
66 | LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("{0} -> {1}",prev.Name, CurrentOperation.Name))); | |
|
66 | //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("{0} -> {1}",prev.Name, CurrentOperation.Name))); | |
|
67 | 67 | return prev; |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | public void Leave() { |
|
71 | 71 | if (m_stack.Count > 0) { |
|
72 | 72 | m_current.Leave(); |
|
73 | var prev = CurrentOperation; | |
|
73 | //var prev = CurrentOperation; | |
|
74 | 74 | m_current = m_stack.Pop(); |
|
75 | LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Leave, String.Format("{0} -> {1}", prev.Name, CurrentOperation.Name))); | |
|
75 | //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Leave, String.Format("{0} -> {1}", prev.Name, CurrentOperation.Name))); | |
|
76 | 76 | } else { |
|
77 | 77 | TraceLog.TraceWarning("Attempt to leave the last operation context"); |
|
78 | 78 | m_current = OperationContext.EMPTY; |
@@ -18,7 +18,8 namespace Implab.Diagnostics { | |||
|
18 | 18 | } |
|
19 | 19 | |
|
20 | 20 | public override string ToString() { |
|
21 | return EventType == TraceEventType.Information ? Message : String.Format("{0}: {1}", EventType, Message); | |
|
21 | /*return EventType == TraceEventType.Information ? Message : String.Format("{0}: {1}", EventType, Message);*/ | |
|
22 | return Message; | |
|
22 | 23 | } |
|
23 | 24 | |
|
24 | 25 | public static TraceEvent Create(TraceEventType type, string format, params object[] args) { |
@@ -89,15 +89,19 namespace Implab | |||
|
89 | 89 | public static IPromise InvokePromise(Func<IPromise> action) { |
|
90 | 90 | ArgumentNotNull(action, "action"); |
|
91 | 91 | |
|
92 | var p = new Promise(); | |
|
93 | 92 | try { |
|
94 | action(); | |
|
95 |
p |
|
|
93 | var p = action(); | |
|
94 | if (p == null) { | |
|
95 | var d = new Promise(); | |
|
96 | d.Reject(new Exception("The action returned null")); | |
|
97 | p = d; | |
|
98 | } | |
|
99 | return p; | |
|
96 | 100 | } catch (Exception err) { |
|
101 | var p = new Promise(); | |
|
97 | 102 | p.Reject(err); |
|
103 | return p; | |
|
98 | 104 | } |
|
99 | ||
|
100 | return p; | |
|
101 | 105 | } |
|
102 | 106 | |
|
103 | 107 | [DebuggerStepThrough] |
General Comments 0
You need to be logged in to leave comments.
Login now