Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenEvent(....)- what does it do?

Status
Not open for further replies.

drewdaman

Programmer
Aug 5, 2003
302
CA
hello,

was wondering if someone could explain to me the purpose of functions such as "OpenEvent" and "OpenMutex"... MSDN is extremely vague about this! For example, the description of "OpenEvent" on MSDN is:

The OpenEvent function opens an existing named event object.

Descriptions for other "open fucntions" are just as vague! i don't know what they mean by "open".

thanks!
 
MSDN (use MSDN search;):

Event Objects
An event object is a synchronization object whose state can be explicitly set to signaled by use of the SetEvent or PulseEvent function. Following are the two types of event object.

Object Description
Manual-reset event An event object whose state remains signaled until it is explicitly reset to nonsignaled by the ResetEvent function. While it is signaled, any number of waiting threads, or threads that subsequently specify the same event object in one of the wait functions, can be released.
Auto-reset event An event object whose state remains signaled until a single waiting thread is released, at which time the system automatically sets the state to nonsignaled. If no threads are waiting, the event object's state remains signaled.


The event object is useful in sending a signal to a thread indicating that a particular event has occurred. For example, in overlapped input and output, the system sets a specified event object to the signaled state when the overlapped operation has been completed. A single thread can specify different event objects in several simultaneous overlapped operations, then use one of the multiple-object wait functions to wait for the state of any one of the event objects to be signaled.

A thread uses the CreateEvent function to create an event object. The creating thread specifies the initial state of the object and whether it is a manual-reset or auto-reset event object. The creating thread can also specify a name for the event object. Threads in other processes can open a handle to an existing event object by specifying its name in a call to the OpenEvent function. For additional information about names for mutex, event, semaphore, and timer objects, see Interprocess Synchronization.

A thread can use the PulseEvent function to set the state of an event object to signaled and then reset it to nonsignaled after releasing the appropriate number of waiting threads. For a manual-reset event object, all waiting threads are released. For an auto-reset event object, the function releases only a single waiting thread, even if multiple threads are waiting. If no threads are waiting, PulseEvent simply sets the state of the event object to nonsignaled and returns.

You must get minimal knowledges about interprocess synchronization before using syn primitives.
 
thanks for teh response...

so it seems that openevent is used only if you want to open teh event from another process.. i just want to use the event in teh same process to synchronize a bunch of threads... am i right in saying that i won't need openevent()?

thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top