Microspeak: To stand up
Today's Microspeak term is stand up, as a verb. This is not to be confused with stand-up as a noun, referring to a short meeting according to the agile development model. It's also not to be confused...
View ArticleWhy is the maximum number of TLS slots 1088? What a strange number.
Commenter Max noted that the maximum number of TLS slots is 1088 and wondered why such a strange number. "I mean, it does not look like a perfect number in terms of 2-based numeric system." It looks a...
View ArticleCustomizing the window handle for item enumeration in IShellItem
Some time ago, I showed how to customize the enumeration flags used when enumerating items with IShellItem. This controls the grfFlags parameter passed to the IShellFolder::EnumObjects method, but...
View ArticleDiscussion of how to add UTF-16 support to a library that internally uses UTF-8
A customer was incorporating an external library that internally manages file names in UTF-8. They wanted to add UTF-16 support¹ and to avoid having to make a lot of changes to the library to change...
View ArticleRevisions to previous discussion of the implementation of anonymous methods...
Welcome to CLR Week. Yes, it's been a long time since the last CLR Week. Some people might consider that a feature. Anyway, I'm going to start by calling attention to some revisions to previous...
View ArticleWhy does the assignment operator in C# evaluate left to right instead of...
When I noted some time ago that the compound assignment operator is guaranteed to evaluate its left hand side before the right hand side, there was much commenting about why the language chose that...
View ArticleDo people write insane code with multiple overlapping side effects with a...
On an internal C# discussion list, a topic that comes up every so often is asking about the correct interpretation of statements like a -= a *= a; p[x++] = ++x; I asked, Who writes code like that with...
View ArticleCrash course in async and await
I'm going to assume that you know how the async and await keywords work. If you need a refresher, you can read Eric Lippert's extensive exposition of the subject. Here's the short version. People who...
View ArticleThe perils of async void
We saw last time that async void is an odd beast, because it starts doing some work, and then returns as soon as it encounters an await, with the rest of the work taking place at some unknown point in...
View ArticleHow can I find out how many threads are active in the CLR thread pool?
A customer was looking for a way to determine programmatically how many threads are active in the CLR thread pool. There is no method that returns this information directly, but you can snap two...
View ArticleIf there is no difference between two options, choose the one that is easier...
In C# you have two ways of casting one object to another. One is to use the as operator, which attempts to casting the object and either returns the successfully cast result or returns null. Another...
View ArticleWrapping up 2017's extended CLR Week-and-a-half with some links to other CLR...
No original content today. Just links to some CLR trivia. Why is the suffix for Decimal literal constants M (Hint: It's not because it stands for Money.) Why doesn't the CLR complain if I use more...
View ArticleTrip report: Sequim Lavender Festival and the Olympic Game Farm
My family took a weekend trip to Sequim for the Sequim Lavender Festival,¹ hosted by the Sequim Lavender Growers Association, and which has the nickname "Lavender Capital of North America."² Here are...
View ArticleHow am I supposed to free the memory the system allocates in the...
A customer noted that the SetPrivateObjectSecurity function updates a pointer provided by the ObjectsSecurityDescriptor parameter. Since it may allocate a new security descriptor, that means that...
View ArticleCan I throw a C++ exception from a structured exception?
A customer wanted to know if it was okay to throw a C++ exception from a structured exception. They explained that they didn't want to compile their project with the /EHa switch, which instructs the...
View ArticleThe redirection can come anywhere on the line, so watch out for those spaces
Wekcome to Batch File Week. Batch is probably one of the most hated programming languages that people are still writing new programs in. You hate it, but you have to deal with it. So just deal with...
View ArticleThe redirection can come anywhere on the line, and you can use that to get...
We saw last time that the redirection can come anywhere on the line, and we saw that unquoted paths with embedded spaces can seem to work, but in fact doesn't. And you don't notice because the command...
View ArticleWhy does attempting to echo an undefined environment variable result in the...
From a batch file, suppose you try to echo the contents of a variable that hasn't been defined: set AWESOME=1 echo %AWESUM% This prints ECHO is off. What's up with that? The first half of the puzzle...
View ArticleDecomposing file paths (and extracting other information like file size, date...
We saw something very similar to this during the first Batch File Week. You have a file name in an environment variable, and you want to decompose its path (say, extract the drive letter or get the...
View ArticleWrapping some other scripting language inside a batch file
Nobody actually enjoys batch programming, but sometimes you can get away with writing in a language you like better while retaining the .cmd extension. Still, that leaves you having to get the...
View Article