public void OpenStream() { _timerWakUp = new Timer(Callback, this, 60 * 1000, 60 * 1000 * 10); Log.DebugFormat("{0} : Open stream ", LinkName); _acsHandle = 0; _invokeId = 0; if (MainLoopResult != null) { Log.DebugFormat("{0} : Wait last main_loop_result", LinkName); MainLoopResult.AsyncWaitHandle.WaitOne(10000); MainLoopResult = null; } _callBackAnkor = EventCallBack; ACSFunctionRet_t ret; lock (GlobalLock) { var pd = new PrivateData_t { vendor = "VERSION" }; pd.Set(PrivateVersion); ret = NativeMethods.acsOpenStream( out _acsHandle, InvokeIDType_t.APP_GEN_ID, 0, StreamType_t.stCsta, Server, Login, Password, AppName, 0, ApiVersion, SendQSize, SendExtraBufs, RecvQSize, RecvExtraBufs, ref pd ); } if (ret == ACSFunctionRet_t.ACSPOSITIVE_ACK) { NativeMethods.acsSetESR(_acsHandle, _callBackAnkor, 0, true); } _waitClient.WaitOne(); foreach (var monitorEventCollection in Monitors) { monitorEventCollection.Value.Dispose(); } Monitors.Clear(); }
protected virtual void Dispose(bool disposing) { Log.DebugFormat("Wait command: {0}", CbTaskNew.CurrentCommand()); Log.DebugFormat("{0} : Destructor", LinkName); if (Disposed) { return; } if (disposing) { } _timerWakUp.Dispose(); _acsHandle = 0; try { _closed.Cancel(false); _closed.Dispose(); } catch (ObjectDisposedException) { //Deleted object } foreach (var variable in CbTaskNew) { variable.Value.Set(null); } CbTaskNew.Clear(); foreach (var variable in Monitors) { variable.Value.Dispose(); } Monitors.Clear(); /*foreach (var variable in Agents) * { * variable.Value.Dispose(); * }*/ // Agents.Clear(); CbEvent = null; _callBackAnkor = null; }