private async Task RunDemo(string url) { cde = new CountdownEvent(invocations); ITaskAgent client = this; ITaskScheduler server = this; var hubConnection = new HubConnection(url); hubConnection.TraceWriter = _traceWriter; _hubProxy = hubConnection.CreateHubProxy("TaskSchedulerHub"); _hubProxy.On <TimeSpan>("RunSync", client.RunSync); _hubProxy.On <TimeSpan>("RunAsync", (data) => client.RunAsync(data)); await hubConnection.Start(new LongPollingTransport()); var smallDuration = TimeSpan.FromMilliseconds(500); var largeDuration = TimeSpan.FromSeconds(10); for (int i = 0; i < invocations; i++) { server.AssignMeShortRunningTask(smallDuration); server.AssignMeLongRunningTask(largeDuration); } cde.Wait(); }