public async Task CanConnectViaLookupConnection() { options.Topic = "foo"; options.Channel = "bar"; var tcs = new TaskCompletionSource <bool>(); using (var consumer = new NsqLookupConsumer(options)) { consumer.InternalMessages += OutputMessage; await consumer.ConnectAndWaitAsync(msg => { tcs.TrySetResult(true); return(msg.FinishAsync()); }); await Task.WhenAll( consumer.SetMaxInFlightAsync(100), consumer.PublishAsync(options.Topic, "hello")); var task = tcs.Task; var done = await Task.WhenAny(task, Task.Delay(1000)); Assert.Same(task, done); } }
public async Task CanConnectViaLookupConnection() { options.Topic = "foo"; options.Channel = "bar"; var tcs = new TaskCompletionSource<bool>(); using (var consumer = new NsqLookupConsumer(options)) { consumer.InternalMessages += OutputMessage; await consumer.ConnectAndWaitAsync(msg => { tcs.TrySetResult(true); return msg.FinishAsync(); }); await Task.WhenAll( consumer.SetMaxInFlightAsync(100), consumer.PublishAsync(options.Topic, "hello")); var task = tcs.Task; var done = await Task.WhenAny(task, Task.Delay(1000)); Assert.Same(task, done); } }
async void ReadyButton_Click(object sender, EventArgs e) { var maxInFlight = int.Parse(ReadyTextBox.Text); await _nsq.SetMaxInFlightAsync(maxInFlight); }