Implementing Asynchronous Calls

Let's start by examining a simple synchronous program that will serve as a jumping-off point for some of the more advanced operators. Listing 4-1 shows a very simple synchronous method. Like all the examples in this chapter, Listing 4-1 should be run in LINQPad.

Listing 4-1. A Synchronous Method

void Main() {   int x = 4;   int y = 5;   int z = AddTwoNumbers(4,5);   z.Dump(); } int AddTwoNumbers(int a, int b) {   return a + b; }

The call to AddTwoNumbers is synchronous, meaning that the processing of Main will pause while AddTwoNumbers is run, not processing the next line (in which the result is output) until the call returns.

Using Observable.Start

Synchronous methods block; and most often this is either undesirable ...

Get Programming Reactive Extensions and LINQ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.