Пример #1
0
        public static void Sample()
        {
            var instance1 = new iRacingEvents();

            instance1.NewData += instance1_NewData;
            instance1.StartListening();

            var iracingInstance = new iRacingConnection();

            var start = DateTime.Now;

            foreach (var data in iracingInstance.GetDataFeed())
            {
                if (DateTime.Now - start > TimeSpan.FromSeconds(1))
                {
                    break;
                }

                traceMessages.Enqueue(string.Format("Enumerable Data Tick {0}", data.Telemetry.TickCount));
            }

            instance1.StopListening();

            foreach (var m in traceMessages)
            {
                Trace.WriteLine(m);
            }
        }
Пример #2
0
        public static void Sample()
        {
            var iracing      = new iRacingConnection();
            var ieventRacing = new iRacingEvents();

            ieventRacing.Connected    += ieventRacing_Connected;
            ieventRacing.Disconnected += ieventRacing_Disconnected;
            ieventRacing.StartListening();

            iracing.Connected    += iracing_Connected;
            iracing.Disconnected += iracing_Disconnected;

            try
            {
                var i = 0;

                foreach (var d in iracing.GetDataFeed())
                {
                    if (i++ % 600 == 0)
                    {
                        Trace.WriteLine(string.Format("Data Stream IsConnected = {0}", d.IsConnected));
                    }
                }
            }
            finally
            {
                ieventRacing.StopListening();
            }
        }
Пример #3
0
        public static void Sample()
        {
            var ieventRacing = new iRacingEvents(1.Seconds());

            ieventRacing.Connected    += ieventRacing_Connected;
            ieventRacing.Disconnected += ieventRacing_Disconnected;
            ieventRacing.NewData      += ieventRacing_NewData;

            Trace.WriteLine("This sample show how to access game data through an event paradigm.");

            //The following statement would be best in your form_load handler
            ieventRacing.StartListening();

            //Simulate a form opened for 10 seconds.
            Thread.Sleep(10000);

            //Stop listening when your app shuts down (say inside your form_unload handler).
            ieventRacing.StopListening();

            Trace.WriteLine("Sample finished.");
        }
        public void Dispose()
        {
            if (null != _iRacingConnection)
            {
                _iRacingConnection.Connected -= _iracing_Connected;
                _iRacingConnection            = null;
            }

            if (null != _iRacingEvents)
            {
                _iRacingEvents.StopListening();
                _iRacingEvents.Connected      -= _iracingEvents_Connected;
                _iRacingEvents.Disconnected   -= _iracingEvents_Disconnected;
                _iRacingEvents.NewData        -= _iracingEvents_NewData;
                _iRacingEvents.NewSessionData -= _iracingEvents_NewSessionData;
                _iRacingEvents.Dispose();
            }

            if (null != _iRacingThread)
            {
                _iRacingThread.Abort();
            }
        }