Auto status change to "Under Review"
@@ -17,7 +17,6 namespace Implab.Diagnostics.Interactive | |||
|
17 | 17 | readonly Promise m_guiStarted = new Promise(); |
|
18 | 18 | |
|
19 | 19 | readonly IPromise m_guiFinished; |
|
20 | // readonly IPromise m_workerFinished = new Promise<object>(); | |
|
21 | 20 | |
|
22 | 21 | readonly MTQueue<TraceViewItem> m_queue = new MTQueue<TraceViewItem>(); |
|
23 | 22 | readonly AutoResetEvent m_queueEvent = new AutoResetEvent(false); |
@@ -30,8 +29,8 namespace Implab.Diagnostics.Interactive | |||
|
30 | 29 | readonly ManualResetEvent m_pauseEvent = new ManualResetEvent(true); |
|
31 | 30 | |
|
32 | 31 | public InteractiveListener() { |
|
33 |
m_guiFinished = |
|
|
34 |
|
|
|
32 | m_guiFinished = RunGuiThread(); | |
|
33 | AsyncPool.RunThread(QueueThread); | |
|
35 | 34 | |
|
36 | 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 | 90 | public void Pause() { |
|
67 | 91 | // for consistency we need to set this properties atomically |
|
68 | 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 | 69 | foreach (var d in objects) |
|
70 |
|
|
|
71 | d.Dispose(); | |
|
70 | Dispose(d); | |
|
71 | } | |
|
72 | ||
|
73 | public static void DisposeCollection(IEnumerable objects) { | |
|
74 | foreach (var d in objects) | |
|
75 | Dispose(d); | |
|
72 | 76 | } |
|
73 | 77 | |
|
74 | 78 | public static void Dispose(object obj) { |
|
75 |
|
|
|
76 | if (d != null) | |
|
77 | d.Dispose(); | |
|
79 | if (obj is IDisposable) { | |
|
80 | Dispose((IDisposable)obj); | |
|
81 | } else if (obj is IEnumerable) { | |
|
82 | Dispose((IEnumerable)obj); | |
|
83 | } | |
|
78 | 84 | } |
|
79 | 85 | |
|
86 | [DebuggerStepThrough] | |
|
80 | 87 | public static void DispatchEvent<T>(this EventHandler<T> handler, object sender, T args) { |
|
81 | 88 | if (handler != null) |
|
82 | 89 | handler(sender, args); |
|
83 | 90 | } |
|
84 | 91 | |
|
92 | [DebuggerStepThrough] | |
|
85 | 93 | public static void DispatchEvent(this EventHandler handler, object sender, EventArgs args) { |
|
86 | 94 | if (handler != null) |
|
87 | 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