
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
1062
|
Chapter 18: Threading and Synchronization
The EventWaitHandle class can also open an existing named event by calling the
OpenExisting method and get the event’s access-control security from GetAccessControl.
When naming events, one consideration is how it will react in the presence of termi-
nal sessions. Terminal sessions are the underlying technology behind Fast User
switching and Remote Desktop, as well as Terminal Services. The consideration is
due to how kernel objects (such as events) are created with respect to the terminal
sessions. If a kernel object is created with a name and no prefix, it belongs to the
Global namespace for named objects and is visible across terminal sessions. By
default,
EventWaitHandle creates the event in the Global namespace. A kernel object
can also be created in the Local namespace for a given terminal session, in which
case the named object belongs to the specific terminal session namespace. If you pass
the Local namespace prefix (Local\[EventName]), then the event will be created in
the local session for events that should be visible from only one terminal session.
// Open the event by local name.
EventWaitHandle ewhSuperBowl =
new EventWaitHandle(false,
EventResetMode.ManualReset,
@"Local\Champs");
Named events can be quite useful not only ...