public async Task Start() { while (!_cts.IsCancellationRequested) { var message = await _queueReader.Dequeue(_cts.Token); using (var nested = _container.GetNestedContainer()) { await nested.GetInstance <IMediator>().Send(message, _cts.Token); } } }
private void Run() { while (true) { bool stop = mStopEvent.WaitOne(0); if (stop) { break; } SendOrPostCallbackItem workItem = mQueueConsumer.Dequeue(); workItem?.Execute(); } }
private void Run() { this.ManagedThreadId = Thread.CurrentThread.ManagedThreadId; while (true) { bool stop = _stopEvent.WaitOne(0); if (stop) { break; } SendOrPostCallbackItem workItem = _consumerQueue.Dequeue(); if (workItem != null) { workItem.Execute(); } } }
private void Run() { ManagedThreadId = Thread.CurrentThread.ManagedThreadId; while (true) { var stop = mStopEvent.WaitOne(0); if (stop) { break; } var workItem = mQueueConsumer.Dequeue(); if (workItem != null) { workItem.Execute(); } } }
public void Process(object doneEvent) { if (!(doneEvent is ManualResetEvent)) { throw new ArgumentException(); } try { while (!_fileProcessData.Cancelled) { ByteBlock block = _queueReader.Dequeue(); if (block == null) { return; } using (var memoryStream = new MemoryStream()) { using (var gzs = new GZipStream(memoryStream, CompressionMode.Compress)) { gzs.Write(block.Buffer, 0, block.Buffer.Length); } byte[] compressedData = memoryStream.ToArray(); var bb = new ByteBlock { Id = block.Id, Buffer = compressedData }; _queueWriter.EnqueueForWriting(bb); } ((ManualResetEvent)doneEvent).Set(); } } catch (Exception ex) { _fileProcessData.Cancelled = true; throw new Exception(ex.Message); } }
private void Run() { SynchronizationContext.SetSynchronizationContext(syncContext); while (true) { bool stop = mStopEvent.WaitOne(0); if (stop) { mQueueConsumer.Dispose(); break; } SendOrPostCallbackItem workItem = mQueueConsumer.Dequeue(); if (workItem != null) { workItem.Execute(); } } }
public void Process(object doneEvent) { if (!(doneEvent is ManualResetEvent)) { throw new ArgumentException(); } try { while (!_fileProcessData.Cancelled) { ByteBlock byteBlock = _queueReader.Dequeue(); if (byteBlock == null) { return; } using (MemoryStream ms = new MemoryStream(byteBlock.CompressedBuffer)) { using (GZipStream gzs = new GZipStream(ms, CompressionMode.Decompress)) { gzs.Read(byteBlock.Buffer, 0, byteBlock.Buffer.Length); byte[] decompressedData = byteBlock.Buffer.ToArray(); ByteBlock block = new ByteBlock { Id = byteBlock.Id, Buffer = decompressedData }; _queueWriter.EnqueueForWriting(block); } ((ManualResetEvent)doneEvent).Set(); } } } catch (Exception ex) { _fileProcessData.Cancelled = true; throw new Exception(ex.Message); } }