Tag: C#

Timers Prior to Async/Await Pattern of C# 5.0

There Are Multiple Ways to Use Task.Delay() When a Timer is Required For scenarios prior to .NET 4.5, several timer classes are available, including System.Windows.Forms.Timer, System.Timers.Timer, and System.Threading.Timer. The development team designed System.Windows.Forms.Timer specifically for use within a rich client user interface. Programmers can drag it onto a form as a non visual control and […]

Master the Basics of MVVM to Simplify Building WPF Applications

Getting Started: Model-View-ViewModel Pattern using Windows Presentation Framework Estimated reading time: 9 minutes The Windows Presentation Framework (WPF) takes full advantage of the Model-View-ViewModel (MVVM) pattern. Though it is possible to create WPF applications without using the MVVM pattern, a little investment in learning can make building WPF applications much simpler. If you are just […]

Deterministic Finalization With IDisposable and the Using Statement

Understanding Deterministic Finalization The problem with finalizers on their own is that they don’t support deterministic finalization (the ability to know when a finalizer will run). Rather, finalizers serve the important role of being a backup mechanism for cleaning up resources if a developer using a class neglects to call the requisite cleanup code explicitly. […]

Guidelines for Exception Handling in C#

Best Practices for Exception Handling The following is a list of C# Exceptions Handling Guidelines taken from Essential C# by Mark Michaelis. Exception handling provides much-needed structure to the error-handling mechanisms that preceded it. However, it can still lead to some unwieldy results if used haphazardly. The following guidelines offer some best practices for exception […]