/// <summary> /// Disposes this instance. /// </summary> public void Dispose() { if (CurrentTimer != null) { CurrentTimer.Dispose(); } Rollback(); if (_dataContext == null) { return; } try { if (_dataContext.Database.GetDbConnection() != null && _dataContext.Database.GetDbConnection().State == System.Data.ConnectionState.Open) { _dataContext.Database.CloseConnection(); } _dataContext.Dispose(); _dataContext = null; } catch (ObjectDisposedException) { _dataContext = null; } }
/// <summary> /// Run when the unit of work is created. /// </summary> private void StartTimer() { if (Timeout == default(Int32)) { Timeout = 60000; } if (CurrentTimer != null) { CurrentTimer.Dispose(); } CurrentTimer = new Timer(OnTimeout, null, Timeout, System.Threading.Timeout.Infinite); }
protected virtual void OnStop() { CurrentTimer.Dispose(); CurrentTimer = null; ChangeStatus(AgentStatus.Stopped); }