public async ValueTask <R> WriteAsync(T data) { var wrap = new DataTaskWrap <T, R>(data); await flowChannel.SendAsync(wrap); if (isProcessing == 0) { TriggerFlowProcess(); } return(await wrap.TaskSource.Task); }
public async Task <R> WriteAsync(T data) { var wrap = new DataTaskWrap <T, R>(data); if (!buffer.Post(wrap)) { await buffer.SendAsync(wrap); } if (consuming == 0) { ThreadPool.QueueUserWorkItem(StartConsumer); } return(await wrap.TaskSource.Task); }