static IEnumerable<DataSample> _GetBufferedDataFeed(iRacingConnection iRacingConnection, int maxBufferLength)
        {
            var que = new ConcurrentQueue<DataSample>();
            bool cancelRequest = false;

            var t = new Task(() => EnqueueSamples(que, iRacingConnection, maxBufferLength, ref cancelRequest));
            t.Start();

            try
            {
                DataSample data;

                while (true)
                {
                    if (que.TryDequeue(out data))
                        yield return data;
                }
            }
            finally
            {
                cancelRequest = true;
                t.Wait(200);
                t.Dispose();
            }
        }
        static IEnumerable <DataSample> _GetBufferedDataFeed(iRacingConnection iRacingConnection, int maxBufferLength)
        {
            var  que           = new ConcurrentQueue <DataSample>();
            bool cancelRequest = false;

            var t = new Task(() => EnqueueSamples(que, iRacingConnection, maxBufferLength, ref cancelRequest));

            t.Start();

            try
            {
                DataSample data;

                while (true)
                {
                    if (que.TryDequeue(out data))
                    {
                        yield return(data);
                    }
                }
            }
            finally
            {
                cancelRequest = true;
                t.Wait(200);
                t.Dispose();
            }
        }
        static void EnqueueSamples(ConcurrentQueue<DataSample> que, iRacingConnection samples, int maxBufferLength, ref bool cancelRequest)
        {
            foreach (var data in samples.GetRawDataFeed())
            {
                if (cancelRequest)
                    return;

                if (que.Count < maxBufferLength)
                    que.Enqueue(data);
                else
                    Debug.WriteLine(string.Format("Warning dropped DataSample {0}.", data.Telemetry.TickCount));
            }
        }
        static void EnqueueSamples(ConcurrentQueue <DataSample> que, iRacingConnection samples, int maxBufferLength, ref bool cancelRequest)
        {
            foreach (var data in samples.GetRawDataFeed())
            {
                if (cancelRequest)
                {
                    return;
                }

                if (que.Count < maxBufferLength)
                {
                    que.Enqueue(data);
                }
                else
                {
                    Debug.WriteLine(string.Format("Warning dropped DataSample {0}.", data.Telemetry.TickCount));
                }
            }
        }
Esempio n. 5
0
 public Replay(iRacingConnection iRacingInstance)
 {
     this.iRacingInstance = iRacingInstance;
 }
 /// <summary>
 /// Similiar to GetDataFeed, except DataSample can be buffered upto maxBufferLength to asist in reducing loss of data packets
 /// Therefore, DataSamples yield from this enumeration may have a higher latency of values.
 /// </summary>
 /// <param name="iRacingConnection"></param>
 /// <param name="maxBufferLength"></param>
 /// <returns></returns>
 public static IEnumerable <DataSample> GetBufferedDataFeed(this iRacingConnection iRacingConnection, int maxBufferLength = 10)
 {
     return(_GetBufferedDataFeed(iRacingConnection, maxBufferLength).WithLastSample());
 }
Esempio n. 7
0
 public Replay(iRacingConnection iRacingInstance)
 {
     this.iRacingInstance = iRacingInstance;
 }
Esempio n. 8
0
 static iRacing()
 {
     instance = new iRacingConnection();
     eventInstance = new iRacingEvents();
 }
Esempio n. 9
0
 static iRacing()
 {
     instance      = new iRacingConnection();
     eventInstance = new iRacingEvents();
 }