void Listen()
        {
            var isConnected           = false;
            var isDisconnected        = true;
            var lastSessionInfoUpdate = -1;

            try
            {
                foreach (var d in instance.GetDataFeed(logging: false))
                {
                    if (requestCancel)
                    {
                        return;
                    }

                    if (!isConnected && d.IsConnected)
                    {
                        isConnected    = true;
                        isDisconnected = false;
                        connected.Invoke();
                    }

                    if (!isDisconnected && !d.IsConnected)
                    {
                        isConnected    = false;
                        isDisconnected = true;
                        disconnected.Invoke();
                    }

                    if (d.IsConnected)
                    {
                        newData.Invoke(d);
                    }

                    if (d.IsConnected && d.SessionData.InfoUpdate != lastSessionInfoUpdate)
                    {
                        lastSessionInfoUpdate = d.SessionData.InfoUpdate;
                        newSessionData.Invoke(d);
                    }
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message, "DEBUG");
                Trace.WriteLine(e.StackTrace, "DEBUG");
            }
            finally
            {
                backListener = null;
            }
        }
示例#2
0
 public static IEnumerable <DataSample> GetDataFeed()
 {
     return(instance.GetDataFeed());
 }