private void readerThread()
        {
            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    if (this.isInit == false)
                    {
                        return;
                    }

                    try
                    {
                        var len = this.reader.ReadInt32();
                        var reqId = this.reader.ReadInt32();
                        var type = this.reader.ReadInt32();
                        var data = len > 10 ? this.reader.ReadBytes(len - 10) : new byte[] { };
                        var pad = this.reader.ReadBytes(2);
                        var msg = new RconMessageAnswer(reqId > -1, data, reqId);
                        this.answers.Add(msg);
                    }
                    catch (EndOfStreamException)
                    {
                        return;
                    }
                    catch (ObjectDisposedException)
                    {
                        return;
                    }
                    catch
                    {
                        return;
                    }

                    Thread.Sleep(1);
                }
            }, TaskCreationOptions.LongRunning);
        }
Esempio n. 2
0
        private void readerThread()
        {
            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    if (this.isInit == false)
                    {
                        return;
                    }

                    try
                    {
                        var len   = this.reader.ReadInt32();
                        var reqId = this.reader.ReadInt32();
                        var type  = this.reader.ReadInt32();
                        var data  = len > 10 ? this.reader.ReadBytes(len - 10) : new byte[] { };
                        var pad   = this.reader.ReadBytes(2);
                        var msg   = new RconMessageAnswer(reqId > -1, data, reqId);
                        this.answers.Add(msg);
                    }
                    catch (EndOfStreamException)
                    {
                        return;
                    }
                    catch (ObjectDisposedException)
                    {
                        return;
                    }
                    catch
                    {
                        return;
                    }

                    Thread.Sleep(1);
                }
            }, TaskCreationOptions.LongRunning);
        }