Chapter 2. Exploring the Top New Features of the CLR

In this chapter, we will cover:

  • Creating a portable library
  • Controlling the timeout in regular expressions
  • Defining the culture for an application domain
  • Overriding the default reflection behavior
  • Using the new ZipArchive class
  • Understanding async and await in .NET 4.5
  • Using the new asynchronous file I/O operations

Introduction

.NET 4.5 brings many benefits, such as improvements in performance, compatibility, garbage collection, and new features in its structure to provide the overall scenarios it is targeted for, for example, Windows Store apps development.

One of its most important characteristics is that it is an in-place substitution of the .NET 4.0 and only runs on Windows Vista SP2 or later systems.

.NET 4.5 breathes asynchronous features and makes writing async code even easier. It also provides us with the Task Parallel Library (TPL) Dataflow Library to help us create parallel and concurrent applications.

Another very important addition is the portable libraries, which allow us to create managed assemblies that we can refer through different target applications and platforms, such as Windows 8, Windows Phone, Silverlight, and Xbox.

We couldn't avoid mentioning Managed Extensibility Framework (MEF), which now has support for generic types, a convention-based programming model, and multiple scopes.

Of course, this all comes together with a brand-new tooling, Visual Studio 2012, which you can find at http://msdn.microsoft.com/en-us/vstudio.Just be careful if you have projects in .NET 4.0 since it is an in-place install.

Note

For this chapter I'd like to give a special thanks to Layla Driscoll from the Microsoft .NET team who helped me summarize the topics, focus on what's essential, and showcase it to you, dear reader, in the most efficient way possible. Thanks, Layla.

There are some features that we will not be able to explore through recipes as they are just there and are part of the CLR but are worth explaining for better understanding:

  • Support for arrays larger than 2 GB on 64-bit platforms, which can be enabled by an option in the app config file.
  • Improved performance on the server's background garbage collection, which must be enabled in the <gcServer> element in the runtime configuration schema.
  • Multicore JIT: Background JIT (Just In Time) compilation on multicore CPUs to improve app performance. This basically creates profiles and compiles methods that are likely to be executed on a separate thread.
  • Improved performance for retrieving resources.
  • The culture-sensitive string comparison (sorting, casing, normalization, and so on) is delegated to the operating system when running on Windows 8, which implements Unicode 6.0. On other platforms, the .NET framework will behave as in the previous versions, including its own string comparison data implementing Unicode 5.0.

Next we will explore, in practice, some of these features to get a solid grasp on what .NET 4.5 has to offer and, believe me, we will have our hands full!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset