public void AddACKCheckEvent(ACKDelegate check_delegate, int timeOut = -1, string timeOutMsg = "", TimeOutDelegate timeout_delegate = null) { if (timeOut > 0) { System.Threading.Timer timer = new System.Threading.Timer( delegate(object state) { if (timeOutEvent != null) { timeOutEvent.Invoke(); } RemoveACKCheckEvent(); //mainForm.ShowMessageBox(timeOutMsg); }, null, timeOut, System.Threading.Timeout.Infinite); ackCheckEvent += delegate() { timer.Dispose(); }; } ackCheckEvent += check_delegate; timeOutEvent += timeout_delegate; }
public void RemoveACKCheckEvent() { ackCheckEvent = null; timeOutEvent = null; }