Book Image

C# 7 and .NET: Designing Modern Cross-platform Applications

By : Mark J. Price, Ovais Mehboob Ahmed Khan
Book Image

C# 7 and .NET: Designing Modern Cross-platform Applications

By: Mark J. Price, Ovais Mehboob Ahmed Khan

Overview of this book

C# is a widely used programming language, thanks to its easy learning curve, versatility, and support for modern paradigms. The language is used to create desktop apps, background services, web apps, and mobile apps. .NET Core is open source and compatible with Mac OS and Linux. There is no limit to what you can achieve with C# and .NET Core. This Learning Path begins with the basics of C# and object-oriented programming (OOP) and explores features of C#, such as tuples, pattern matching, and out variables. You will understand.NET Standard 2.0 class libraries and ASP.NET Core 2.0, and create professional websites, services, and applications. You will become familiar with mobile app development using Xamarin.Forms and learn to develop high-performing applications by writing optimized code with various profiling techniques. By the end of C# 7 and .NET: Designing Modern Cross-platform Applications, you will have all the knowledge required to build modern, cross-platform apps using C# and .NET. This Learning Path includes content from the following Packt products: • C# 7.1 and .NET Core 2.0 - Modern Cross-Platform Development - Third Edition by Mark J. Price • C# 7 and .NET Core 2.0 High Performance by Ovais Mehboob Ahmed Khan
Table of Contents (25 chapters)
Title Page
Copyright
About Packt
Contributors
Preface
16
Designing Guidelines for .NET Core Application Performance
Index

Avoiding finalizers


Using finalizers is not a good practice to use in .NET Core applications. Objects that use finalizers stay in memory longer and ultimately affect the application's performance.

Objects that are not required by the application at a particular point in time stay in the memory so that their Finalizer method can be called. For example, if the object is considered dead by the GC in generation 0, it will always survive in generation 1.

In .NET Core, CLR maintains a separate thread to run the Finalizer method. All the objects that contain the Finalizer method are placed into the finalization queue. Any object that is no longer required by the application is placed in the F-Reachable queue, which is then executed by the dedicated finalizer thread.

The following diagram shows an object1 object that contains a Finalizer method. The Finalizer method is placed in the finalization queue and the object occupies the memory space in the Gen0 (generation 0) heap:

When the object is no longer...