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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.