15 ms·
Out of interest, is this any different to WaitHandles + async delegates in .NET? Doesn't look like it to me but I could be missing something: Func<string>
by bruceboughton 16y ago
Out of interest, is this any different to WaitHandles + async delegates in .NET? Doesn't look like it to me but I could be missing something:
Func<string> reader = read;
IAsyncResult future_x = reader.BeginInvoke(null, null)
IAsyncResult future_y = reader.BeginInvoke(null, null)
WaitHandle.WaitAll(new[] { future_x.AsyncWaitHandle, future_y.AsyncWaitHandle }); // takes optional timeout
string x = reader.EndInvoke(future_x);
string y = reader.EndInvoke(future_y);
write(x + y);
- pmjordan 16y agoLooks like it's essentially the same type of programming model, although I have a feeling WaitHandle.WaitAll() just blocks the current thread. In the ideal case, it would internally call the event loop coroutine and process other events instead without sending the thread to sleep. Thread scheduling involves system (kernel) calls, coroutines are purely userspace, just like node.js's async callback mechanism.