Exemplo n.º 1
0
        /// <summary>
        /// Initilises a new instance of the <see cref="AK.F1.Timing.Server.Proxy.ProxySessionManager"/>
        /// class and specified the source <see cref="AK.F1.Timing.IMessageReader"/>.
        /// </summary>
        /// <param name="reader">The source <see cref="AK.F1.Timing.IMessageReader"/>.</param>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when <paramref name="reader"/> is <see langword="null"/>.
        /// </exception>        
        public ProxySessionManager(IMessageReader reader)
        {
            Guard.NotNull(reader, "reader");

            _messageReader = reader;
            _cancellationToken = _cancellationTokenSource.Token;
            _readMessagesTask = new Task(ReadMessagesTask, _cancellationToken);
            _readMessagesTask.ContinueFaultWith(_ => Dispose());
            _readMessagesTask.Start();
            _mainTask = new Task(MainTask, _cancellationToken);
            _mainTask.ContinueFaultWith(_ => Dispose());
            _mainTask.Start();
        }