protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { if (_query != null) { _query.OnTerminate -= OnTerminate; _query.OnOtherAck -= OnOtherAck; _query.OnAdviseData -= OnAdviseData; _query.OnExecute -= OnExecute; _query.OnExecuteAck -= OnExecuteAck; _query.OnRequestData -= OnRequestData; _query.Dispose(); _query = null; } if (_app != null) { _app.Dispose(); _app = null; } } disposedValue = true; } }