Пример #1
0
        protected virtual void RecvLoop()
        {
            while (RecvThread != null)
            {
                try
                {
                    using (var pipe = new NamedPipeClientStream(PipeName))
                    {
                        using (var reader = new LogReader(pipe))
                        {
                            pipe.Connect(0);

                            IsConnected = pipe.IsConnected;

                            while (pipe.IsConnected)
                            {
                                var obj = reader.Read();
                                if (obj != null)
                                {
                                    if (obj is FlashObject)
                                    {
                                        DoProcessObject((FlashObject)obj);
                                    }
                                    else if (obj is string)
                                    {
                                        DoProcessLine((string)obj);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (IOException)
                {
                    //Pipe was broken, lets start listening again
                }
                catch (TimeoutException)
                {
                }
                catch (Exception ex)
                {
                    StaticLogger.Error(ex);
                }
                finally
                {
                    IsConnected = false;
                }

                Thread.Sleep(500);
            }
        }
Пример #2
0
        protected virtual void RecvLoop()
        {
            while (RecvThread != null)
            {
                try
                {
                    using (var pipe = new NamedPipeClientStream(PipeName))
                    {
                        using (var reader = new LogReader(pipe))
                        {
                            pipe.Connect(0);

                            IsConnected = pipe.IsConnected;

                            while (pipe.IsConnected)
                            {
                                var obj = reader.Read();
                                if (obj != null)
                                {
                                    if (obj is FlashObject)
                                        DoProcessObject((FlashObject)obj);
                                    else if (obj is string)
                                        DoProcessLine((string)obj);
                                }
                            }
                        }
                    }
                }
                catch (IOException)
                {
                    //Pipe was broken, lets start listening again
                }
                catch (TimeoutException)
                {
                }
                catch (Exception ex)
                {
                    StaticLogger.Error(ex);
                }
                finally
                {
                    IsConnected = false;
                }

                Thread.Sleep(500);
            }
        }