Example #1
0
        /// <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;
            }
        }
Example #2
0
        /// <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);
        }
Example #3
0
 protected virtual void OnStop()
 {
     CurrentTimer.Dispose();
     CurrentTimer = null;
     ChangeStatus(AgentStatus.Stopped);
 }