Changeset 3250 for trunk/sources
- Timestamp:
- 04/01/10 15:36:10 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/AsynchronousContentView.cs
r3229 r3250 25 25 /// <param name="method">The delegate to invoke.</param> 26 26 protected new void Invoke(Delegate method) { 27 IAsyncResult res = base.BeginInvoke(method); 28 ThreadPool.RegisterWaitForSingleObject(res.AsyncWaitHandle, 29 new WaitOrTimerCallback((x, b) => { EndInvoke(res); }), 30 null, -1, true); 27 // prevent blocking of worker thread in Invoke, if the control is disposed 28 IAsyncResult result = BeginInvoke(method); 29 result.AsyncWaitHandle.WaitOne(1000, false); 30 if (result.IsCompleted) EndInvoke(result); 31 else { 32 ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, 33 new WaitOrTimerCallback((x, b) => { try { EndInvoke(result); } catch (InvalidOperationException) { } }), 34 null, -1, true); 35 } 31 36 } 37 32 38 /// <summary> 33 39 /// Asynchronous call of GUI updating. … … 36 42 /// <param name="args">The invoke arguments.</param> 37 43 protected new void Invoke(Delegate method, params object[] args) { 38 IAsyncResult res = base.BeginInvoke(method, args); 39 ThreadPool.RegisterWaitForSingleObject(res.AsyncWaitHandle, 40 new WaitOrTimerCallback((x, b) => { EndInvoke(res); }), 41 null, -1, true); 44 // prevent blocking of worker thread in Invoke, if the control is disposed 45 IAsyncResult result = BeginInvoke(method, args); 46 result.AsyncWaitHandle.WaitOne(1000, false); 47 if (result.IsCompleted) EndInvoke(result); 48 else { 49 ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, 50 new WaitOrTimerCallback((x, b) => { try { EndInvoke(result); } catch (InvalidOperationException) { } }), 51 null, -1, true); 52 } 42 53 } 43 54 }
Note: See TracChangeset
for help on using the changeset viewer.