Interfacing with Multithreading Patterns prior to TPL and C# 5.0

,
April 9, 2018 / 2 Comments

Legacy Blog – Pre C# 5.0
Multithreading patterns are used to address the multithreading complexities of monitoring an asynchronous operation, thread pooling, avoiding deadlocks, and implementing atomicity and synchronization across operations and data access.
This is a thorough blog that combs through all you’d need to know about multithreading if you were working in a legacy version of C#. Although […]
Read more

AUTHOR: CATEGORY: .Net, C#, Uncategorized

Using Tuples for overriding Equality() and GetHashCode()

,
March 28, 2018 / No Comment

The implementation of Equals() and GetHashCode() used to be complex, but with C# 7.0 Tuples, the actual code is boilerplate.

For Equals(): It’s necessary to compare all the contained identifying data structures while avoiding infinite recursion or null reference exceptions.
For GetHashCode(): It’s necessary to combine the unique hash code of each of the non-null contained identifying data structures […]
Read more

AUTHOR: CATEGORY: Blog, C#

The Essential C# 7.0 book is almost here!

,
March 19, 2018 / No Comment

The newest edition of Mark Michaelis’ Essential C# book releases May 28th.

“Mark is super smart, insists on understanding everything to the core, and has phenomenal insight into how things affect real developers. . . . He goes right to the essence and communicates with great integrity—no sugarcoating—and has a keen eye for practical value and real-world problems.”
—From […]
Read more

AUTHOR: CATEGORY: Headlines

Timers Prior to Async/Await Pattern of C# 5.0

,
October 9, 2017 / No Comment

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 nonvisual control and regulate the behavior from within the […]
Read more

AUTHOR: CATEGORY: .Net, Blog, C#, Toubleshooting

Getting started with Model-View-ViewModel (MVVM) pattern using Windows Presentation Framework (WPF)

,
September 19, 2017 / No Comment

The Windows Presentation Framework (WPF) is built to take 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 getting started with WPF I would suggest taking a look at this getting started guide.
Read more

AUTHOR: CATEGORY: C#, WPF

C# 7.0: Tuples Explained

,
July 27, 2017 / No Comment

Back in November, in the Connect() special issue of MSDN Magazine, I provided an overview of C# 7.0 in which I introduced tuples. Click here for the overview. In this blog I delve into tuples again, covering the full breadth of the syntax options.
To begin, let’s consider the question:
Why tuples?
On occasion, you’ll likely find it useful to […]
Read more

AUTHOR: CATEGORY: Blog

Deterministic Finalization with IDisposable and the Using Statement

,
October 14, 2016 / No Comment

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.
For example, consider the TemporaryFileStream, which includes not […]
Read more

AUTHOR: CATEGORY: .Net, Blog, C#

Locking a Block of Code With an Integer

,
June 27, 2016 / No Comment

I was talking with a developer recently who was convinced that you could use a static integer variable to lock a block of code merely by casting it to an object, like this

First it must be noted that an integer cannot be used by itself in a lock statement because it is a value type. But when you […]
Read more

AUTHOR: CATEGORY: .Net, Blog, C#

Guidelines for Exception Handling in C#

,
September 14, 2015 / 1 Comment

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 handling.

Catch only the exceptions that you can handle.
Read more

AUTHOR: CATEGORY: .Net, C#

IntelliTect Presents at the Seattle Code Camp 2012

,
June 15, 2012 / No Comment

Asynchronous Programming with C# 5.0 – Mark Michaelis
In C# 5.0 there is really only one significant syntax addition – support for asynchronous programming that is embedded into the language. In this session we go over the is and is-nots of what C# 5.0 enables in the way of parallel processing – both for the UI and for the server […]
Read more

AUTHOR: CATEGORY: .Net, C#, Headlines, PowerShell