I am going over the ParallelFX code at the moment, and I run into this interesting method.
Platform.Yield(), which turn out to be a call to SwitchToThread(), which is a method I really should have known about. Turn out that this is a way to explicitly give up the current time-slice that the thread is executing (for the current CPU only).
This lead me to do some more discovery, and I found this, managed fibers implementations (I can't find the source for this, however, and I have the SDK). This is all part of my quest to get Erlang-like support for concurrency. By that I mean that I can do things like:
public void Process() { var dbFuture = Spawn( AquireDataFromDB ); var wsFuture = Spawn( AquureDataFromWS ); YieldUntil(dbFuture, wsFuture); // do real processing here. }
The key point is that the call to YieldUntil does not block the current thread, instead, it frees it to do start executing additional processing.
We can keep abusing the yield return approach, but that is starting to get old.