public void SetInitializedState() { if (_state != EDisposableObjectState.Created) throw new WrongDisposableObjectStateException() { ActualState = _state }; _state = EDisposableObjectState.Initialized; }
public void SetInitializedState() { if (_state != EDisposableObjectState.Created) { throw new WrongDisposableObjectStateException() { ActualState = _state } } ; _state = EDisposableObjectState.Initialized; }
public async Task MyDisposeAsync() { if ( _state != EDisposableObjectState.Initialized && _state != EDisposableObjectState.Created ) { throw new WrongDisposableObjectStateException() { ActualState = _state } } ; _state = EDisposableObjectState.Disposing; Task zeroCounterTask = _zeroFuncTrigger.FirstAsync().ToTask(); if (_runningFuncCounter == 0) { return; } /**/ bool measureDisposingTime = _stateHelperId != ""; var sw = new Stopwatch(); if (measureDisposingTime) { sw.Start(); _logger.Trace( "StateHelper dispose enter {0}, counters - '{1}'", _stateHelperId, _methodIdCounters.Where(x => x.Value.Item1 > 0).ToArray().WriteObjectToJson() ); } await zeroCounterTask.ConfigureAwait(false); /**/ _state = EDisposableObjectState.Disposed; if (measureDisposingTime) { _logger.Trace("StateHelper dispose leave {0}", _stateHelperId); sw.Stop(); if (sw.ElapsedMilliseconds > 5000) { _logger.Trace( "StateHelper Dispose exceeds time limit id:{0}", _stateHelperId ); } } } }
public async Task MyDisposeAsync() { if ( _state != EDisposableObjectState.Initialized && _state != EDisposableObjectState.Created ) throw new WrongDisposableObjectStateException() { ActualState = _state }; _state = EDisposableObjectState.Disposing; Task zeroCounterTask = _zeroFuncTrigger.FirstAsync().ToTask(); if (_runningFuncCounter == 0) return; /**/ bool measureDisposingTime = _stateHelperId != ""; var sw = new Stopwatch(); if (measureDisposingTime) { sw.Start(); _logger.Trace( "StateHelper dispose enter {0}, counters - '{1}'", _stateHelperId, _methodIdCounters.Where(x => x.Value.Item1 > 0).ToArray().WriteObjectToJson() ); } await zeroCounterTask.ConfigureAwait(false); /**/ _state = EDisposableObjectState.Disposed; if (measureDisposingTime) { _logger.Trace("StateHelper dispose leave {0}", _stateHelperId); sw.Stop(); if (sw.ElapsedMilliseconds > 5000) { _logger.Trace( "StateHelper Dispose exceeds time limit id:{0}", _stateHelperId ); } } }