C

Download Multithreading in C# 5.0 Cookbook by Eugene Agafonov PDF

By Eugene Agafonov

Over 70 recipes that will help you examine asynchronous and parallel programming with C# 5.0 quick and efficiently

Overview

  • Delve deep into the .NET threading infrastructure and use activity Parallel Library for asynchronous programming
  • Scale out your server functions effectively
  • Master C# 5.0 asynchronous operations language support

In Detail

In an age whilst machine processors are being constructed to include increasingly more cores, multithreading is a key issue for developing scalable, potent, and responsive purposes. in the event you fail to do it effectively, it may well bring about difficult difficulties that take a massive period of time to unravel. for this reason, having a fantastic figuring out of multithreading is a needs to for the fashionable program developer.

Multithreading in C# 5.0 Cookbook is an easy-to-understand consultant to the main difficult programming difficulties. This publication will consultant you thru functional examples devoted to quite a few points of multithreading in C# on home windows and should offer you a great foundation of useful wisdom that you could then use to application your personal scalable and trustworthy multithreaded purposes.

This booklet publications you thru asynchronous and parallel programming from uncomplicated examples to functional, real-world strategies to advanced difficulties. you'll commence from the very starting, studying what a thread is, after which continue to benefit new suggestions in response to the knowledge you get from the former examples.

After describing the fundamentals of threading, it is possible for you to to know extra complicated innovations like job Parallel Library and C# asynchronous features. Then, we circulation in the direction of parallel programming, beginning with simple information constructions and progressively progressing to the extra complex styles. The publication concludes with a dialogue of the specifics of home windows eight program programming, supplying you with an entire knowing of the way home windows eight functions are varied and the way to software asynchronous functions for home windows 8.

What you are going to study from this book

  • Work with uncooked threads, synchronize threads, and coordinate their work
  • Develop your individual asynchronous API with job Parallel Library
  • Use C# 5.0 asynchronous language features
  • Scale up your server software with I/O threads
  • Parallelize your LINQ queries with PLINQ
  • Use universal concurrent collections
  • Apply various parallel programming patterns
  • Work with home windows eight asynchronous APIs
  • Use Reactive Extensions to run asynchronous operations and deal with their options

Approach

This publication is an easy-to-follow advisor packed with hands-on examples of real-world multithreading projects. each one subject is defined and put in context, and for the extra inquisitive readers, there also are extra in-depth info of the thoughts used.

Who this booklet is written for

If you're a developer or new to multithreaded programming and also you are trying to find a brief and straightforward option to start, then this e-book is for you. it really is assumed that you've a few event in C# and .NET already, and also you must also be accustomed to computing device technological know-how and uncomplicated algorithms and knowledge structure.

Show description

Read or Download Multithreading in C# 5.0 Cookbook 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 crucial suggestions by way of supplying brief factors, in addition to examples, and routines.

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

What's solid code? Writing sturdy code can be a query approximately what the code is attempting to resolve. (And strong code isn't really to be burdened with styles simply because no longer all items of fine code are styles. ) We debate approximately stable code simply because there isn't only a unmarried piece of fine code, yet such a lot of reliable items of code.

Expert .NET Micro Framework

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

Additional resources for Multithreading in C# 5.0 Cookbook

Sample text

This method runs a sequence of increment/decrement operations on an object. Initially, the Counter object is not thread-safe and we get a race condition here. So in the first case, a counter value is not deterministic. We could get a zero value; however, if you run the program several times, you will eventually get some incorrect nonzero result. In Chapter 1, Threading Basics, we resolved this problem by locking our object, causing other threads to block while one thread gets the old counter value, then computes and assigns a new value to the counter.

To understand how to use the C# lock keyword, perform the following steps: Start Visual Studio 2012. Count); Run the program. How it works... When the main program starts, it first creates an object of the class Counter. This class defines a simple counter that can be incremented and decremented. Then we start three threads that share the same counter instance and perform an increment and decrement in a cycle. This leads to nondeterministic results. If we run the program several times, it will print out several different counter values.

How it works... When the main program starts, it defines two threads that will throw an exception. One of these threads handles exception, while the other does not. You can see that the second exception is not caught by a try/catch block around a code that starts the thread. So if you work with threads directly, the general rule is to not throw an exception from a thread, but to use a try/catch block inside a thread code instead. 1), this behavior was different and uncaught exceptions did not force an application shutdown.

Download PDF sample

Rated 4.35 of 5 – based on 32 votes