2

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.

Jimmy Hoffa
  • 5,909
  • 30
  • 53

2 Answers2

7

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.

Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
0

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.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • For such a high rep you really ignored my question :P The uniqueness I desire is up to me; if I was going to use a guid I would leave it unnamed so it is process-local, nay class or method local. I want a system-wide eventwaithandle so that I can let the whole machine know "Hey, if you're trying to request the URL right now wait in line or grab it from memcached, because I'm requesting it right now". I'm fine with creating my own solution, what I needed was just to know if my name would violate any kernel restrictions. I ended up canning the URL and using Request_{the urls hashcode} anyway. – Jimmy Hoffa Aug 23 '13 at 01:29
  • I, like the OP, am trying to synchronize things which are related to each other by configuration. In my case, I have some strings that may contain any characters but which are unique to the set of processes which need to wait together. There is currently no mechanism to generate and then copy a GUID to all of the processes in the group which need to be associated with each other. I need to know which characters to filter out or transform from my existing unique grouping identifier string because that is way simpler than using GUIDs ;-). Now, a message digest sounds easy… – binki Sep 20 '18 at 22:02
  • Also, what if GUIDs used characters that were illegal/meangingful in `EventWaitHandle` names? – binki Sep 20 '18 at 22:03
  • It always struck me as mysterious how SO users downvote an answer and then expect a response on their "I am not going to click the Ask Question button" comment anyway. At least it makes sense when their user name matches a notoriously onerous person, one who everybody stopped helping 4 years ago. "binki" doesn't ring a bell. Noted in little black book. – Hans Passant Sep 20 '18 at 22:11