private void mSync_Unlocked(object sender, EventArgs e) { if (base.InvokeRequired) { try { if (!this.gotLock) { IAsyncResult asyncResult = base.BeginInvoke(new MethodInvoker(this.reflectGUI)); while (!asyncResult.IsCompleted && !asyncResult.AsyncWaitHandle.WaitOne(300, false)) { } base.EndInvoke(asyncResult); } } catch { this.exited = true; } if (this.exited) { if (this.mSync != null) { this.mSync.Unlocked -= this.mSync_Unlocked; } this.mSync = null; } } }
public void ToolSyncObject(HalSyncObject objSync, bool autoUpdate) { if (objSync == null) { this.exited = true; if (autoUpdate && this.mSync != null && this.mSync.TryLock()) { this.mSync.Unlocked -= this.mSync_Unlocked; this.mSync.Unlock(); } } else { this.exited = false; this.mSync = objSync; if (autoUpdate) { this.mSync.Unlocked += this.mSync_Unlocked; } } }