C

Download Async in C# 5.0: Unleash the Power of Async by Alex Davies PDF

By Alex Davies

In case you are writing one of the functions that decision for asynchronous programming, this concise hands-on consultant exhibits you the way the async characteristic in C# 5.0 could make the method a lot less complicated. in addition to a transparent creation to asynchronous programming, you get an in-depth examine how the async characteristic works and why you have to use it on your program. Written for knowledgeable C# programmers - but approachable for newbies - this booklet is filled with code examples so you might expand to your personal tasks.

Show description

Read or Download Async in C# 5.0: Unleash the Power of Async PDF

Similar c# books

A Basic UNIX Tutorial

This educational includes fourteen sections, each one of which addresses a primary element of UNIX computing. It concentrates on illustrating the relevant techniques by way of delivering brief reasons, besides examples, and workouts.

How to Code .NET: Tips and Tricks for Coding .NET 1.1 and .NET 2.0 Applications Effectively

What's solid code? Writing reliable code is known as a query approximately what the code is making an attempt to resolve. (And solid code isn't to be harassed with styles simply because no longer all items of excellent code are styles. ) We debate approximately solid code simply because there isn't only a unmarried piece of excellent code, yet such a lot of reliable items of code.

Expert .NET Micro Framework

The Microsoft . web Micro Framework is a small and effective . internet runtime setting used to run controlled code on units which are too small and source restricted for home windows CE and the Compact Framework. professional . web Micro Framework will train you every little thing you must recognize which will use the .

Extra resources for Async in C# 5.0: Unleash the Power of Async

Example text

NET version and settings, may be lost or even rethrown on an unexpected thread, terminating the process. We’ll see better ways to do this in Chapter 7. Async Method Return Types There are three return types that a method marked async may have: • void • Task • Task for some type T No other return type is allowed because async methods in general aren’t finished when they return. Typically, an async method will await a long-running operation, which means that the method returns quickly, but will resume in the future.

Despite that, async is not part of the signature of the method, in terms of overriding other methods, implementing interfaces, or being called. The only effect that the async keyword has is on the compilation of the method to which it is applied, unlike the other keywords that are applied to a method, which change how it interacts with the outside world. Because of this, the rules around overriding methods and implementing interfaces completely ignore the async keyword. class BaseClass { public virtual async Task AlexsMethod() { ...

Task; } Of course, this is such a useful little tool that it’s provided in the framework. Delay, and of course the framework version is more powerful, robust, and probably more efficient than mine. Waiting for a Collection of Tasks As we saw back in “Task and await” on page 20, it’s very easy to run multiple asynchronous operations in parallel by calling them in turn, then awaiting them in turn. What we’ll find out in Chapter 9 is that it’s important that we await each and every Task that we start, otherwise exceptions can get lost.

Download PDF sample

Rated 4.75 of 5 – based on 3 votes