Never make assumptions about performance

The importance of measuring performance changes is a topic that has been covered by others smarter and more experienced than me, but I have a recent simple tale.
I’ve simplified the code quite a bit in order to demonstrate the issue. Suppose I have a wrapper around an image (it has many more attributes):

[...]

Popularity: 3% [?]

Easily Unit Testing Event Handlers

In C#, If you need to unit test a class that fires an event in certain circumstances (perhaps even asynchronously), you need to handle a little more than just running some code and doing the assertion. You have to make sure your unit test waits for the event to be fired. Here’s one naive way [...]

Popularity: 3% [?]

Pausing a Thread Safely

In .Net you have the option of Thread.Suspend() and Thread.Abort(), but under normal circumstances these are horrible options to use because they’re likely to create locking problems (i.e., the thread has a locks on resource that other threads need).
A far better way is to signal to the thread that it should pause and wait for a signal to continue.  [...]

Popularity: 1% [?]

Threads in MFC Part III: Exceptions, Suspense, Murder, and Safety

Exceptions
In the previous tutorial, I described the various synchronization objects you can use to control access to shared objects. In most cases, these will work fine, but consider the following situation:
[code lang="cpp"]
UINT ThreadFunc(LPVOID lParam)
{
::criticalSection.Lock();
::globalData.DoSomething();
SomeFunctionThatThrowsException();
::criticalSection.Unlock();
return 0;
}[/code]
What’s going to happen when that exception gets thrown? The critical section will never be unlocked. If you start the thread [...]

Popularity: 1% [?]

Threads in MFC II: Synchronization Objects

Introduction
In part I, I looked at getting threads communicating with each other. Now let’s look at how we can manage how multiple threads operate on single objects.
Let’s take an example. Suppose we have a global variable (or any variable that is accessible to two or more threads via scope, pointers, references, whatever). Let’s say this [...]

Popularity: 12% [?]

Threads in MFC I: Worker Threads

There are two types of threads in MFC. Worker and User Interface. Here, I will discuss how to use a worker thread.First, let’s discuss some multi-threading basics. Each application has what we call a process. Usually, an application has only one process. This process defines all the code and memory space for the application. You [...]

Popularity: 11% [?]