Пример #1
0
        protected override void DaemonMethod()
        {
            _connectionTime = DateTime.MinValue;
            while (!ShouldDisconnect)
            {
                Thread.Sleep(TickTime);
                Rf2FullData      rFactorData = Load();
                SimulatorDataSet dataSet;
                try
                {
                    dataSet = _rf2DataConvertor.CreateSimulatorDataSet(rFactorData);
                }
                catch (RF2InvalidPackageException)
                {
                    continue;
                }

                if (CheckSessionStarted(rFactorData, dataSet))
                {
                    RaiseSessionStartedEvent(dataSet);
                }

                RaiseDataLoadedEvent(dataSet);

                if (!IsProcessRunning())
                {
                    ShouldDisconnect = true;
                }
            }
            Disconnect();
            RaiseDisconnectedEvent();
        }
Пример #2
0
        protected override async Task DaemonMethod(CancellationToken cancellationToken)
        {
            _connectionTime = DateTime.MinValue;
            while (!ShouldDisconnect)
            {
                await Task.Delay(TickTime, cancellationToken).ConfigureAwait(false);

                Rf2FullData      rFactorData = Load();
                SimulatorDataSet dataSet;
                try
                {
                    dataSet = _rf2DataConvertor.CreateSimulatorDataSet(rFactorData);
                }
                catch (RF2InvalidPackageException ex)
                {
                    if (ex.InnerException != null)
                    {
                        Logger.Error(ex, "RF2Invalid Package Caused by Exception");
                    }
                    continue;
                }

                if (CheckSessionStarted(rFactorData, dataSet))
                {
                    _sessionTimeInterpolator.Reset();
                    RaiseSessionStartedEvent(dataSet);
                }

                _previousSessionTime = dataSet.SessionInfo.SessionTime;
                RaiseDataLoadedEvent(dataSet);

                if (!IsProcessRunning())
                {
                    ShouldDisconnect = true;
                }
            }
            Disconnect();
            RaiseDisconnectedEvent();
        }