.NET system-wide EventWaitHandle name allowed characters

1.5k views Asked by At

I'm just curious off hand, are there any restrictions on the naming of a system-wide EventWaitHandle? I want to use a URL as the name for one, but it could have a great deal of odd characters, I don't want it to silently fail or some other such, so just checking up on here if there are any known illegal characters for the names of these.

I tried finding this myself, but my google-fu wasn't up to snuff.

2

There are 2 answers

1
Jim Mischel On BEST ANSWER

Here it is. See the CreateEvent function documentation.

The name can have a "Global\" or "Local\" prefix to explicitly create the object in the global or session namespace. The remainder of the name can contain any character except the backslash character (\).

Also see Kernel Object Namespaces.

The "Session\" prefix is reserved for system use and you should not use it in names of kernel objects.

4
Hans Passant On

This is the wrong way to think about this. By far the most important feature of the name that you pick is that is unique. People suck at picking unique names, there are far too many guys called Hans in this world.

Leave it up to a machine to pick a globally unique ID. You already know it as a Guid. In Visual Studio, click Tools + Create GUID. Bullet #4 is what you want, copy/paste it into your code and put quotes around it. Prefix with Global\\ to make it system-wide.