concept Reactive Extensions in category .net

appears as: Reactive Extensions
Concurrency in .NET

This is an excerpt from Manning's book Concurrency in .NET.

During an interview on Microsoft’s Channel 9 (http://bit.ly/2v8exjV), Erik Meijer, the mind behind Rx, mentioned that F# was an inspiration for the creation of Reactive Extensions. One of the inspiring ideas behind the Reactive framework, composable events, does in fact come from F#.

Listing 12.10 Integrating Reactive Extensions with TDF
inputBuffer.LinkTo(compressor, linkOptions);
compressor.LinkTo(encryptor, linkOptions);

encryptor.AsObservable()   #1  
         .Scan((new Dictionary<int, EncryptDetails>(), 0), 
 (state, msg) => Observable.FromAsync(async() => {   #2  
 (Dictionary<int,EncryptDetails> details, int lastIndexProc) = state;
 details.Add(msg.Sequence, msg);
 while (details.ContainsKey(lastIndexProc + 1)) {
    msg = details[lastIndexProc + 1];
    await streamDestination.WriteAsync(msg.EncryptedDataSize, 0, 
                                       msg.EncryptedDataSize.Length);
    await streamDestination.WriteAsync(msg.Bytes, 0, msg.Bytes.Length);
    lastIndexProc = msg.Sequence;
    details.Remove(lastIndexProc);
    } 
 return (details, lastIndexProc);
}) .SingleAsync().Wait())
.SubscribeOn(TaskPoolScheduler.Default).Subscribe();   #3  

#1   Enables Rx integration with TDF
#2   Runs the Rx Scan operation asynchronously
#3   Rx subscribes to TaskPoolScheduler