The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
Weak references have no effect on object lifetime
The class lets you retain a reference to an object while still permitting the object to be garbage collected. When that happens, then the property is and the property is . (Related discussion.) Note, however, that weak references do not alter the decision of the garbage collector whether or not an object is garbage. It merely lets you observe the garbage collector's decision. Some people think that means "Treat this as a regular (strong) reference most of the time, but if there is memory pressure, then you can reclaim the object." This type of reference is called a in Java, but the CLR has no analogous co...
Sometimes sports-rule lawyering comes true: The strikeout with only one thrown pitch
Some time ago, I engaged in some sports-rule lawyering to try to come up with a way the losing team could manage to salvage a win without any remaining at-bats. It involved invoking a lot of obscure rules, but astonishingly one of the rules that I called upon was actually put into effect a few days ago. The Crawfish Boxes provides an entertaining rundown of the sequence of events. Here is the boring version: During his plate appearance, Vinnie Catricala was not pleased with the strike call on the first pitch he received. He exchanged words with the umpire, then stepped out of the batter's box to adjust his e...
The mysterious ways of the params keyword in C#
If a parameter to a C# method is declared with the keyword, then it can match either itself or a comma-separated list of um itselves(?). Consider: This program prints The first call to does not take advantage of the keyword and passes the array explicitly (formally known as normal form). The second call, however, specifies the integers directly as if they were separate parameters. The compiler generates a call to the function in what the language specification calls expanded form. Normally, there is no conflict between these two styles of calling a function with a parameter because only one form act...
A practical reason for shutting down for the Mayan apocalyse
I dreamed that Costco announced that they were closing for the Mayan apocalypse and would reopen two weeks later. Not because they believed in it. Rather, because that was their estimate as to how long it would take people to get through their stockpiles and be ready to go shopping again. Curiously, I had this dream several weeks after the apocalypse date had passed.
Why does BitConverter.LittleEndian return false on my x86 machine?
Welcome to CLR Week 2013, returned from its two-year hiatus. A customer reported that when they checked with the debugger, reported even though they were running on an x86 machine, which is a little-endian architecture. The bytes are extracted in little-endian order, despite the claim that the machine is big-endian. "I don't get it." I didn't know the answer, but I knew how to use a search engine, and a simple search quickly found this explanation: Reading a member from the debugger merely reads the value of the member from memory. That simple statement hides the answer by saying what happens and l...
It rather involved being on the other side of this airtight hatchway: Open access to the application directory
You can't just let anybody into your safety bubble.
The case of the auto-hide taskbar
A customer reported that their taskbar would sometimes spontaneously go into auto-hide mode. What made this particularly insidious was that they had deployed a group policy to prevent users from changing the auto-hide state (because they never wanted the taskbar to auto-hide), so when the taskbar went into auto-hide mode, there was no way to get it out of that mode! The customer's first investigation was to find out where the auto-hide state was recorded. A little bit of registry spelunking (because as far as these people are concerned, everything is in the registry) showed that a single bit in the registry v...
Why does Explorer sometimes show my server name in parentheses?
A customer wanted to know why Explorer showed one of their servers in the folder list the normal way: ⊞ servername but another server showed up "where the server name is parentheses and the node name is in front." ⊞ nodename (servername) "Where is Explorer getting that information, and why are the two servers showing up in different ways?" It's all in the server comment. From the command line, you can view the server comment by typing . For example, You can set the comment with the command line If a server has a comment, then the comment is shown to the user on the expectation tha...
Sometimes people can be so helpless: Finding the owner of a Web page
Internal to Microsoft are thousands of Web sites. This is a story about one of them. On an internal discussion list, somebody asked We just created a new Flurb. Does anyone know how to get listed on http://internalsite/newflurbs? I hadn't heard of that site before, but I checked it out. Neat, it's basically a blog which announces new Flurbs. I can see how somebody would want their Flurb to be listed there. I also saw lots of pieces of information on the page which the person appears not to have noticed. I replied, Um, how about the Email link in the navigation bar? Or did you try that and it didn't work? ...