O'Reilly logo

Programming Reactive Extensions and LINQ by Paul Betts, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required