コード例 #1
0
        private void ProcessQueue()
        {
            while (true)
            {
                MungEvent msg;
                if (_connection.State == ConnectionState.Connected)
                {
                    while (_q.TryDequeue(out msg))
                    {
                        try {
                            SimpleTimer.DebugTime("event-send", () => {
                                _connection.Send(msg);
                            });
                            Debug.WriteLine("MUNG: sent: " + JsonConvert.SerializeObject(msg));
                        } catch (Exception ex) {
                            System.Diagnostics.Debug.WriteLine(string.Format("MUNG: Unable to send event: {0}", ex.Message));
                        }
                    }
                }
                else
                {
                    if (_connection.State == ConnectionState.Disconnected)
                    {
                        System.Diagnostics.Debug.WriteLine(string.Format("MUNG: Connecting to {0}", _connectionUrl));
                        _connection.Start();
                        //Console.WriteLine("Mung not connected");
                        Thread.Sleep(1000);
                    }
                }

                Thread.Sleep(100);
            }
        }