The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

It's fine to use fibers, but everybody has to be on board with the plan
Feb 26, 2010
Post comments count 0
Post likes count 0

It's fine to use fibers, but everybody has to be on board with the plan

Raymond Chen
Raymond Chen

We saw fibers a long time ago when I looked at how you can use fibers as a form of coroutines to simplify the writing of enumerators. A fiber is a handy tool, but it's a tool with very sharp edges. Since fibers are promiscuous with threads, you have to be careful when running code that cares about what thread it is running on, because that code may discover that its thread changed out from under it. For example, critical sections and mutexes remember which thread owns them. If you enter a critical section on a fiber, and then you unschedule the fiber, then reschedule it onto a different thread, and then you l...

Food products that are offenses against nature: Bagel-fuls
Feb 25, 2010
Post comments count 0
Post likes count 0

Food products that are offenses against nature: Bagel-fuls

Raymond Chen
Raymond Chen

Wow, it's been a long time since my last rant against food products that are offenses against nature. Today's rant is against Bagel-fuls, a product which Kraft launched in April 2008. Bagel-fuls (note the hyphen and the lowercase "f") are a dense, doughy material formed into a log shape, with a cream cheese filling. Think of them as Twinkies, but with cream cheese instead of a sugar cream filling, and with a dense, doughy substance instead of whatever alien material it is they make Twinkies out of. The great thing about this product is that it is an attempt by Kraft to learn its lesson from a previous faile...

What happens to the fibers which ran on a thread when the thread exits?
Feb 25, 2010
Post comments count 0
Post likes count 0

What happens to the fibers which ran on a thread when the thread exits?

Raymond Chen
Raymond Chen

What happens to the fibers which ran on a thread when the thread exits? Are all the fibers destroyed? No, only the currently-executing fiber is destroyed. Fibers running on other threads and fibers which are not running on any thread at all are not affected. Fibers do not have thread affinity (when not running), and they do not remember what threads they have been run on. Indeed, one of the features of fibers is that you can switch away from a fiber on one thread, then switch to that same fiber on another thread, and that fiber will resume execution on the new thread. Fibers are the social butterflies of schedu...

German language tip: Matratzen = mattresses, Matrosen = sailors
Feb 24, 2010
Post comments count 0
Post likes count 0

German language tip: Matratzen = mattresses, Matrosen = sailors

Raymond Chen
Raymond Chen

Be careful not to confuse the two. Since we're sharing: During a conversation in German, I talked about seeing Unfall (accident) instead of Abfall (garbage) on the street. To my credit, I immediately corrected my error. To my discredit, the error was made at the state finals of a German language contest.

Why does the CBS_SORT combo box style sort the left square bracket so strangely?
Feb 24, 2010
Post comments count 0
Post likes count 1

Why does the CBS_SORT combo box style sort the left square bracket so strangely?

Raymond Chen
Raymond Chen

Some time ago, Michael Kaplan asked (and answered), How the @#%&*! does choose to sort it all out? One detail in his answer is that the sorting algorithm used by is basically , with special treatment for the left square bracket U+005B. Why is the left square bracket so special? It goes back to the message (which is in turn used by , , , and related functions). If you ask for drives to be added to the list or combo box, they are added in the form , where is the drive letter. The left square bracket is special-cased so that the drive letters sort to the top of the list. Of course, and related functions...

Le Chatelier's principle in action: Announcements
Feb 23, 2010
Post comments count 0
Post likes count 0

Le Chatelier's principle in action: Announcements

Raymond Chen
Raymond Chen

As I noted some time ago, one of the most important lessons I learned from Systemantics is Le Chatelier's Principle for complex systems which states, "Every complex system resists its proper functioning." At Microsoft, there are processes galore. For example, when a server is taken down for planned maintenance, you can expect a series of messages, perhaps following this pattern: The problem with this is that you often receive notifications for servers you have no interest in, indeed whose mere existence you were previously entirely unaware of. The notification messages don't include instructions on how to st...

On the Internet, everybody wants to know if you're a dog
Feb 22, 2010
Post comments count 0
Post likes count 0

On the Internet, everybody wants to know if you're a dog

Raymond Chen
Raymond Chen

On Slate, Michael Agger expounds on increasing pressure for people to provide pictures of themselves online. I've managed to resist so far. That article also tipped me off to a phenomenon I didn't even know had a name: MySpace angles.

Custom navigation in dialog boxes, redux
Feb 22, 2010
Post comments count 0
Post likes count 0

Custom navigation in dialog boxes, redux

Raymond Chen
Raymond Chen

SuperBK asks, "What's the proper way to add keyboard support to a dialog box?" There are many options available to you. The most traditional way is to pick them off in the dialog loop, either hard-coding the keys in code or putting them into resources by moving them to an accelerator resource. Moving them to an accelerator resource is a good idea if the keys are subject to translation (for example, if they are mnemonic). On the other hand, picking them off in code is your only choice if the action you want to take cannot be mapped to a message (or if you simply don't feel like creating such a mapping). Super...

How many servings are there in a single-serve cup? The answer might surprise you
Feb 19, 2010
Post comments count 0
Post likes count 0

How many servings are there in a single-serve cup? The answer might surprise you

Raymond Chen
Raymond Chen

I was in the grocery store, and there was a sign advertising a new product. Delight in a cup Your favorite XYZ Ice Cream Now in convenient single-serve cups. I took a look at the cup. Seemed kind of big for a single serving. I picked one up to read the nutritional information. Servings per container: 2