NanoByte.Common.Streams.CircularBufferStream.RelayErrorToReader C# (CSharp) Method

RelayErrorToReader() public method

Throws an exception from within Read.
public RelayErrorToReader ( Exception exception ) : void
exception System.Exception The exception to throw.
return void
        public void RelayErrorToReader(Exception exception)
        {
            lock (_lock)
                _relayedException = exception;

            // Stop waiting for data that will never come
            _dataAvailable.Set();
        }

Usage Example

Esempio n. 1
0
        public void TestErrorRelay()
        {
            // Throw exception on producer thread after a short delay
            new Thread(() =>
            {
                Thread.Sleep(50);
                _stream.RelayErrorToReader(new InvalidDataException("Test exception"));
            }).Start();

            // Catch exception on consumer thread
            _stream.Invoking(x => x.Read(2)).ShouldThrow <InvalidDataException>();
        }
All Usage Examples Of NanoByte.Common.Streams.CircularBufferStream::RelayErrorToReader