The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

The dangers of sleeping on a UI thread
Feb 10, 2006
Post comments count 0
Post likes count 1

The dangers of sleeping on a UI thread

Raymond Chen
Raymond Chen

If you have a thread that owns a window, you should not be using the function, because that causes your thread to stop responding to messages for the duration of the sleep. This is true even for sleeps of short duration, such as sleeping for a few seconds and waking up in order to poll the state of something in the system. As we noted earlier, polling is bad for system performance, impairing the system's ability to conserve energy in low power scenarios and suffering from the magnifying effects of Terminal Server. If you're idle, stay idle. If you're busy, do your work and then go idle. Unfortunately, I occa...

Shifting from program management to programming also affects your social life
Feb 9, 2006
Post comments count 0
Post likes count 0

Shifting from program management to programming also affects your social life

Raymond Chen
Raymond Chen

My colleague who switched from program management to programming has this to say about unintended consequences: My take on this is that I developed through the needs of my job as a lead program manager the ability to talk to anyone at any time to get a particular issue dealt with, but that I didn't necessarily want to do this or enjoy the process. After work or on the weekends, my wife was hard pressed to get me to see other people. Now, there is no such issue. The reduction in forced human interaction is such that I am no longer overstretching my ability to interact with people, thus rendering me able to un...

Comparing writing specifications to writing code
Feb 8, 2006
Post comments count 0
Post likes count 0

Comparing writing specifications to writing code

Raymond Chen
Raymond Chen

My colleague who manages to pack his entire office into a single box recently made the switch from program management to programming. I teased him, "So what's it like using an editor without a 'boldface' button?" His response was actually rather insightful. "Writing specifications is like writing a novel. Writing code is like writing poetry." When you're writing a specification, you need to start by setting the scene so people understand the problem you're trying to solve. You then explore the world you've created, elaborating on the details necessary to convey your intent, considering all the possibilities an...

Apparently I can't take myself anywhere
Feb 7, 2006
Post comments count 0
Post likes count 0

Apparently I can't take myself anywhere

Raymond Chen
Raymond Chen

Upon arriving at the office, I unpack my bicycle bag and remove a crisp new white shirt. I change into my work clothes, and then at 11am, I head to lunch as I usually do. (This is the lunch group that includes JeffDav and occasionally BenCon.) I get a sandwich, sit down, and immediately drip sauce on my brand new shirt. Can't even keep a shirt clean for two hours. Fortunately, I keep a spare shirt in my office so I am able to change and give the now-no-longer-purely-white shirt a bit of a wash in the bathroom sink before the stain set.

Viewing function composition as transformation of the domain
Feb 7, 2006
Post comments count 0
Post likes count 0

Viewing function composition as transformation of the domain

Raymond Chen
Raymond Chen

A lot of formulas you encounter in computer science can be viewed as function composition. Let's start with the simple problem of rounding integers down to the nearest multiple of some positive constant. The formula for this should be relatively easy for you to produce: round_down(n, m) = floor_div(n, m) * m where returns the largest integer less than or equal to n/m. If n≥0 and m>0, then where is the C integer division operator. But what if you want to round up? Take a look at the difference between rounding up and rounding down, say, using multiples of four for concreteness. The table is jus...

You know you're in trouble when your channel loses to dead air
Feb 6, 2006
Post comments count 0
Post likes count 0

You know you're in trouble when your channel loses to dead air

Raymond Chen
Raymond Chen

When Australian Channel Seven aired a blank screen for 41 minutes [indirect report], you'd think its competition would pick up some viewers. But it didn't. But the glitch did not result in a ratings boost for public broadcaster SBS, with figures showing viewers preferred Seven's blank screen. To Seven's astonishment more than 900,000 viewers stayed tuned to the network after screens went blank 38 minutes into the nail-biting episode. "Around a million Australians hung in there for us and we thank them for their commitment," Seven Sydney spokesman Simon Francis said last night. (The Chaser, Australia...

Beware of redirected folders, too
Feb 6, 2006
Post comments count 0
Post likes count 0

Beware of redirected folders, too

Raymond Chen
Raymond Chen

Earlier, we learned about roaming user profiles, wherein the master copy of the user's profile is kept on a central server (which for the purpose of discussion I will call the "profile server") and is copied around to follow the user as she logs onto computers throughout an organization. In the comments, many people said that what they really want is for the files to be stored in a central location without any copying. That is what redirected folders gives you. Redirected folders are a way for a domain administrator to specify that selected folders in the user profile (for example, the Desktop, the Start menu,...

You can't even trust the identity of the calling executable
Feb 3, 2006
Post comments count 0
Post likes count 0

You can't even trust the identity of the calling executable

Raymond Chen
Raymond Chen

A while back, I demonstrated that you can't trust the return address. What's more, you can't even trust the identity of the calling executable. I've seen requests from people who say, "I want to check whether I'm being called from MYAPP.EXE. I'm going to make a security decision based on the result." Although you can do this, all it does is give you more rope. Even if you are convinced that you're being called from the expected application, you aren't any safer. An attacker can inject code into that process (say, via a global hook) and you will foolishly trust it. In the same way that you shouldn't trust who y...

Mysterious things Steve Yi has eaten
Feb 3, 2006
Post comments count 0
Post likes count 0

Mysterious things Steve Yi has eaten

Raymond Chen
Raymond Chen

I read with some fascination Steven Yi's Mysterious Things I Have Eaten, since I have had four out of five of them myself. And I love the little story he tells about sea cucumber. Kimchee, like lutefisk and surströmming, most likely comes from the days before refrigeration. The acid produced by fermentation preserves (what's left of) the food. Oh, and if you're keeping score: