internal AsyncFlushHandler(IBatchFactory batchFactory, IRequestHandler requestHandler, int maxQueueSize) { _queue = new BlockingQueue <BaseAction>(); this._batchFactory = batchFactory; this._requestHandler = requestHandler; this.MaxQueueSize = maxQueueSize; // set that the queue is currently empty _idle = new ManualResetEvent(true); _continue = new CancellationTokenSource(); // start the long running flushing task Task.Factory.StartNew(() => Loop(), _continue.Token); }
internal AsyncFlushHandler(IBatchFactory batchFactory, IRequestHandler requestHandler, int maxQueueSize) { _queue = new BlockingQueue <BaseAction>(); this._batchFactory = batchFactory; this._requestHandler = requestHandler; this.MaxQueueSize = maxQueueSize; _continue = true; // set that the queue is currently empty _idle = new ManualResetEvent(true); // start the flushing thread _flushingThread = new Thread(new ThreadStart(Loop)); _flushingThread.Start(); }