The Old New Thing

A dream about forgetting to deploy the backup brake pads

I dreamed that that I was driving through a parking garage when my brakes suddenly failed. I tried executing turns to bleed off speed, but it was largely ineffective. I managed to avoid hitting a parked police car (which had arrived to investigate some other accident), but was unable to avoid another parked car. An insurance adjuster who was ...

The tiny table sorter – or – you can write LINQ in JavaScript

I had a little side project that displayed status information in a table, and I figured, hey, let me add sorting. And it was a lot easier than I thought. I just put the header row in the THEAD and the table contents in the TBODY, then I could use this code to sort the table: Each cell can have an optional sort­Key custom attribute ...
Comments are closed.0Code

If I signal an auto-reset event and there is a thread waiting on it, is it guaranteed that the event will be reset and the waiting thread released before SetEvent returns?

Let's go straight to the question: I have two programs that take turns doing something. Right now, I manage the hand-off with two auto-reset events. In Thread A, after it finishes doing some work, it signals Event B and then immediately waits on Event A. Thread B does the converse: When its wait on Event B ...
Comments are closed.0Code

How do I control the order of the pages in property sheets from my shell extension?

A customer wanted to know whether a shell extension can control the order of the property sheet pages in a property sheet. The IShell­Prop­Sheet­Ext interface lets you add pages and replace pages, but nothing about rearranging them. Naturally a shell extension can control the relative order of its own pages (by changing in the ...
Comments are closed.0Code

What's the point of letting you change the GCL_CBCLSEXTRA if it has no effect?

The documentation for the Set­Class­Long­Ptr function mentions GCL_CB­CLS­EXTRA: Sets the size, in bytes, of the extra memory associated with the class. Setting this value does not change the number of extra bytes already allocated. What's the point of letting the application change a value if it has no effect? The ...
Comments are closed.0Code

Generally speaking, yanking the power plug unexpectedly should not be part of your business process

A customer had a complex process for setting up their computers, and the process recorded information in the registry so that applications could record their state across reboots. They then noticed that if they yanked the power cord instead of going through the normal Shutdown process, that the registry keys were not reliably updated. They ...
Comments are closed.0Other

Please don't wade across the Strait of Juan de Fuca

I dreamed that I was visiting a scenic location near the Canadian border. A central large body of water had the mainland to the south and east. A river ran southeast, spanned by a footbridge. To the northwest was another land mass, which had gained the nickname "Alaska" even though we were nowhere near Alaska. There was a gift shop on "Alaska...

How do I convert a synchronous file handle into an asynchronous one?

Say you opened a file in synchronous mode, and then you realize that you want to issue asynchronous I/O on it, too. One way to do this is to call Create­File a second time with the FILE_FLAG_OVERLAPPED, but this requires you to know the file name, and the file name may not be readily available to the function that wants to do the ...
Comments are closed.0Code

Each time I move, my mailbox moves further away

When I was growing up, the mailman letter carrier came right to our front door. The mailbox was mounted on the front of the house right next to the front door. You could check the mail without even getting dressed; just open the door a crack and stick out your hand. Approximate distance from front door to mailbox: less than 1 foot. In ...

Why does the CLR report a NullReferenceException even if the referenced access is not exactly the null pointer?

We saw some time ago that before invoking a method on an object, the CLR will generate a cmp [ecx], ecx instruction to force a null reference exception to be raised if you are trying to invoke a method on a null reference. But why does the CLR raise a Null­Reference­Exception if the faulting address is almost but not quite zero...
Comments are closed.0Code