.comment-link {margin-left:.6em;}

I Hate Linux

Thursday, August 16, 2007

System wide named event my hiney

One issue I ran into late into the game with DHCP4WHS was alerting the server from the client UI that some settings had changed... to do that I used a named EventWaitHandle instance to define a 'system wide' event that could be triggered in one app and responded to in another. Seems pretty simple right?

It is... so long as 'system wide' only refers to 'user session wide.' Shame the MSDN documentation doesn't make that clear.

Why is that important? One unique a case you run into when writing an add-in for WHS that lives within the Home Server Console is that when used remotely... your add-in (along with the console) live within a separate user session of Windows which means your add-in that creates a named event is actually using a different one than what the rest of your code running in a different session is using.

Moral of the story? For a truly 'system wide' named event one needs to prefix the name with "Global\".

Added that... problem solved… only it took me 3 hours to find this newsgroup thread before I had a fix.

2 Comments:

  • The Win32 equivalent CreateEvent[1] does mention this and points to "Kernel Object Namespaces" [2]which explains the defaults and why this is the way it is. It's a shame that's not included with the .NET documentation.

    [1] http://msdn2.microsoft.com/en-us/library/ms682396.aspx
    [2] http://msdn2.microsoft.com/en-us/library/aa382954.aspx

    By Anonymous Peter Ritchie, at 10:48 AM  

  • Good point, I guess I didn’t dig deep enough into the underlying implementation of EventWaitHandle.

    By Blogger Brendan, at 2:36 PM  

Post a Comment

<< Home