Auto status change to "Under Review"
@@ -17,7 +17,6 namespace Implab.Diagnostics.Interactive | |||||
17 | readonly Promise m_guiStarted = new Promise(); |
|
17 | readonly Promise m_guiStarted = new Promise(); | |
18 |
|
18 | |||
19 | readonly IPromise m_guiFinished; |
|
19 | readonly IPromise m_guiFinished; | |
20 | // readonly IPromise m_workerFinished = new Promise<object>(); |
|
|||
21 |
|
20 | |||
22 | readonly MTQueue<TraceViewItem> m_queue = new MTQueue<TraceViewItem>(); |
|
21 | readonly MTQueue<TraceViewItem> m_queue = new MTQueue<TraceViewItem>(); | |
23 | readonly AutoResetEvent m_queueEvent = new AutoResetEvent(false); |
|
22 | readonly AutoResetEvent m_queueEvent = new AutoResetEvent(false); | |
@@ -30,8 +29,8 namespace Implab.Diagnostics.Interactive | |||||
30 | readonly ManualResetEvent m_pauseEvent = new ManualResetEvent(true); |
|
29 | readonly ManualResetEvent m_pauseEvent = new ManualResetEvent(true); | |
31 |
|
30 | |||
32 | public InteractiveListener() { |
|
31 | public InteractiveListener() { | |
33 |
m_guiFinished = |
|
32 | m_guiFinished = RunGuiThread(); | |
34 |
|
|
33 | AsyncPool.RunThread(QueueThread); | |
35 |
|
34 | |||
36 | m_guiStarted.Join(); |
|
35 | m_guiStarted.Join(); | |
37 | } |
|
36 | } | |
@@ -63,6 +62,31 namespace Implab.Diagnostics.Interactive | |||||
63 | } |
|
62 | } | |
64 | } |
|
63 | } | |
65 |
|
64 | |||
|
65 | public IPromise RunGuiThread() { | |||
|
66 | var p = new Promise(); | |||
|
67 | ||||
|
68 | var caller = TraceContext.Instance.CurrentOperation; | |||
|
69 | ||||
|
70 | var worker = new Thread(() => { | |||
|
71 | TraceContext.Instance.EnterLogicalOperation(caller, false); | |||
|
72 | try { | |||
|
73 | Application.OleRequired(); | |||
|
74 | GuiThread(); | |||
|
75 | p.Resolve(); | |||
|
76 | } catch (Exception e) { | |||
|
77 | p.Reject(e); | |||
|
78 | } finally { | |||
|
79 | TraceContext.Instance.Leave(); | |||
|
80 | } | |||
|
81 | }); | |||
|
82 | worker.SetApartmentState(ApartmentState.STA); | |||
|
83 | worker.IsBackground = true; | |||
|
84 | worker.Name = string.Format("{0} GUI Thread", nameof(InteractiveListener)); | |||
|
85 | worker.Start(); | |||
|
86 | ||||
|
87 | return p; | |||
|
88 | } | |||
|
89 | ||||
66 | public void Pause() { |
|
90 | public void Pause() { | |
67 | // for consistency we need to set this properties atomically |
|
91 | // for consistency we need to set this properties atomically | |
68 | lock (m_pauseLock) { |
|
92 | lock (m_pauseLock) { |
@@ -65,23 +65,31 namespace Implab | |||||
65 | } |
|
65 | } | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | public static void Dispose(IEnumerable<IDisposable> objects) { |
|
68 | public static void DisposeCollection(IEnumerable<IDisposable> objects) { | |
69 | foreach (var d in objects) |
|
69 | foreach (var d in objects) | |
70 |
|
|
70 | Dispose(d); | |
71 | d.Dispose(); |
|
71 | } | |
|
72 | ||||
|
73 | public static void DisposeCollection(IEnumerable objects) { | |||
|
74 | foreach (var d in objects) | |||
|
75 | Dispose(d); | |||
72 | } |
|
76 | } | |
73 |
|
77 | |||
74 | public static void Dispose(object obj) { |
|
78 | public static void Dispose(object obj) { | |
75 |
|
|
79 | if (obj is IDisposable) { | |
76 | if (d != null) |
|
80 | Dispose((IDisposable)obj); | |
77 | d.Dispose(); |
|
81 | } else if (obj is IEnumerable) { | |
|
82 | Dispose((IEnumerable)obj); | |||
|
83 | } | |||
78 | } |
|
84 | } | |
79 |
|
85 | |||
|
86 | [DebuggerStepThrough] | |||
80 | public static void DispatchEvent<T>(this EventHandler<T> handler, object sender, T args) { |
|
87 | public static void DispatchEvent<T>(this EventHandler<T> handler, object sender, T args) { | |
81 | if (handler != null) |
|
88 | if (handler != null) | |
82 | handler(sender, args); |
|
89 | handler(sender, args); | |
83 | } |
|
90 | } | |
84 |
|
91 | |||
|
92 | [DebuggerStepThrough] | |||
85 | public static void DispatchEvent(this EventHandler handler, object sender, EventArgs args) { |
|
93 | public static void DispatchEvent(this EventHandler handler, object sender, EventArgs args) { | |
86 | if (handler != null) |
|
94 | if (handler != null) | |
87 | handler(sender, args); |
|
95 | handler(sender, args); |
General Comments 3
ok, latest stable version should be in default
You need to be logged in to leave comments.
Login now