Пример #1
0
        public bool Wait(int millisecondsTimeout)
        {
            if (millisecondsTimeout < 0)
            {
                throw new NotSupportedException();
            }


            _isEventSet      = false;
            _simulationEvent = new SetSimulatedResetEventEvent(this, _engine.CurrentTime.AddMilliseconds(millisecondsTimeout));
            _engine.AddEvent(_simulationEvent);
            _blockSimulationEvent?.Set(); // continue simulation.
            _mainEvent.WaitOne();
            return(_isEventSet);
        }
Пример #2
0
        public void Set()
        {
            _isEventSet = true;
            if (_blockSimulation == null)
            {
                _blockSimulation = new BlockSimulationEvent(this, _engine);
                _engine.AddEvent(_blockSimulation);
            }
            else
            {
                _blockSimulationEvent.Reset();
            }

            if (_simulationEvent != null)
            {
                _engine.CancelEvent(_simulationEvent);
                _simulationEvent = null;
            }

            _mainEvent.Set();
        }
Пример #3
0
 /// <summary>
 /// Sets event and waits until thread, waiting for the event, is done. Then continues simulation.
 /// </summary>
 internal void SetEvent()
 {
     _simulationEvent = null;
     _mainEvent.Set();
     _blockSimulationEvent?.WaitOne();
 }