public void Run()
        {
            Logger.Info("Starting ZkClient event thread.");
            try
            {
                while (!this.tokenSource.IsCancellationRequested)
                {
                    ZkEvent zkEvent = this._events.Take();
                    int     eventId = this._eventId.GetAndIncrement();
                    Logger.Debug("Delivering event #" + eventId + " " + zkEvent);
                    try
                    {
                        zkEvent.RunAction();
                    }
                    catch (ThreadInterruptedException)
                    {
                        this.tokenSource.Cancel();
                    }
                    catch (Exception e)
                    {
                        Logger.Error("Error handling event " + zkEvent, e);
                    }

                    Logger.Debug("Delivering event #" + eventId + " done");
                }
            }
            catch (ThreadInterruptedException)
            {
                Logger.Info("Terminate ZkClient event thread.");
            }
        }
コード例 #2
0
ファイル: ZkEventThread.cs プロジェクト: CMTelecom/kafka-net
 public void Send(ZkEvent zkEvent) 
 {
     if (!this.tokenSource.IsCancellationRequested) 
     {
         Logger.Debug("New event: " + zkEvent);
         this._events.Add(zkEvent);
     }
 }
 public void Send(ZkEvent zkEvent)
 {
     if (!this.tokenSource.IsCancellationRequested)
     {
         Logger.Debug("New event: " + zkEvent);
         this._events.Add(zkEvent);
     }
 }