Book Image

C# 7 and .NET Core 2.0 High Performance

By : Ovais Mehboob Ahmed Khan
Book Image

C# 7 and .NET Core 2.0 High Performance

By: Ovais Mehboob Ahmed Khan

Overview of this book

While writing an application, performance is paramount. Performance tuning for realworld applications often involves activities geared toward fnding bottlenecks; however, this cannot solve the dreaded problem of slower code. If you want to improve the speed of your code and optimize an application's performance, then this book is for you. C# 7 and .NET Core 2.0 High Performance begins with an introduction to the new features of what?explaining how they help in improving an application's performance. Learn to identify the bottlenecks in writing programs and highlight common performance pitfalls, and learn strategies to detect and resolve these issues early. You will explore multithreading and asynchronous programming with .NET Core and learn the importance and effcient use of data structures. This is followed with memory management techniques and design guidelines to increase an application’s performance. Gradually, the book will show you the importance of microservices architecture for building highly performant applications and implementing resiliency and security in .NET Core. After reading this book, you will learn how to structure and build scalable, optimized, and robust applications in C#7 and .NET.
Table of Contents (11 chapters)
Designing Guidelines for .NET Core Application Performance

Evolution of .NET

In early 2002, when Microsoft first introduced the .NET Framework, it targeted developers who were working on classic ASP or VB 6 platforms since they didn't have any compelling framework for developing enterprise-level applications. With the release of the .NET Framework, developers had a platform to develop applications and could choose any of the languages from VB.NET, C#, and F#. Irrespective of the language chosen, the code is interoperable, and developers can create a project with VB.NET and reference it in their C# or F# project and vice versa.

The core component of .NET Framework includes Common Language Runtime (CLR), Framework Class Libraries (FCL), Base Class Libraries (BCL), and a set of application models. New features and patches have been introduced with the newer version of the .NET Framework, which comes with the new release of Windows, and developers have had to wait for a year or so to get those improvements. Every team at Microsoft worked on a different application model, and each team had to wait for the date when the new framework was released to port their fixes and improvements. Windows Forms and Web Forms were the primary application models at that time that were widely used by .NET developers.

When Web Forms was first introduced, it was a breakthrough which attracted both web developers who worked on Classic ASP and desktop application developers who worked on Visual Basic 6.0. The developer experience was appealing and provided a decent set of controls that could easily be dragged and dropped to the screen, followed to their events and properties that could be set either through the view file (.aspx) or code-behind files. Later on, Microsoft introduced the Model View Controller (MVC) application model that implemented the separation of concerns design principle, so that View, Model, and Controller are separate entities. The View is the user interface that renders the Model, where the Model represents the business entity and holds the data, and the Controller that handles the request and updates the model and injects it into the View. MVC was a breakthrough that let developers write cleaner code and bind their model with the HTML controls using model binding. With the passage of time, more features were added and the core .NET web assembly System.Web became quite big and bloated, and contained lots of packages and APIs that were not always useful in every type of application. However, with .NET, several groundbreaking changes were introduced and System.Web got split into NuGet packages that can be referenced and added individually based on requirements.

.NET Core (codename .NET vNext) was first introduced in 2014, and the following are the core benefits of using .NET Core:



Cross Platform

.NET Core can run on Windows, Linux, and macOS

Host Agnostic

.NET Core on the server side is not dependent on IIS and, with two lightweight servers, Kestrel and WebListener, it can be self-hosted as a Console application and can be also gelled with mature servers such as IIS, Apache, and others through a reverse proxy option


Ships as NuGet packages

Open Source

The entire source code is released as open source via the .NET Foundation

CLI tooling

Command line tools to create, build, and run projects from the command line

.NET Core is a cross-platform, open-source framework that implements .NET Standard. It provides a runtime known as .NET Core CLR, framework class libraries, which are primitive libraries known as CoreFX, and APIs that are similar to what .NET Framework has, but have a smaller footprint (lesser dependencies on other assemblies):

.NET Core provides flexible deployment options as follows:

  • Framework-Dependent Deployment (FDD): needs .NET Core SDK to be installed on the machine
  • Self-Contained Deployment (SCD): No machine-wide installation of .NET Core SDK is needed on the machine and .NET Core CLR and framework class libraries are part of the application package
To install .NET Core 2.0, you can navigate to the following link and go through the options for installing it on Windows, Linux, MAC, and Docker.