xtd 0.2.0
Loading...
Searching...
No Matches

◆ event_wait_handle() [7/8]

xtd::threading::event_wait_handle::event_wait_handle ( bool  initial_state,
event_reset_mode  mode,
const string name 
)

Initializes a new instance of the xtd::threading::event_wait_handle class, specifying whether the wait handle is initially signaled if created as a result of this call, whether it resets automatically or manually, and the name of a system synchronization event.

Parameters
initial_statetrue to set the initial state to signaled; false to set it to nonsignaled.
modeOne of the xtd::threading::event_reset_mode values that determines whether the event resets automatically or manually.
nameThe name, if the synchronization object is to be shared with other processes; otherwise, null or an empty string. The name is case-sensitive. The backslash character () is reserved and may only be used to specify a namespace. For more information on namespaces, see the remarks section. There may be further restrictions on the name depending on the operating system. For example, on Unix-based operating systems, the name after excluding the namespace must be a valid file name.
Exceptions
xtd::argument_excpetionThe mode enum value was out of legal range.
xtd::io::io_exceptionname is invalid. This can be for various reasons, including some restrictions that may be placed by the operating system, such as an unknown prefix or invalid characters. Note that the name and common prefixes "Global\" and "Local" are case-sensitive.
-or-
There was some other error. The HResult property may provide more information.
xtd::io::path_to_long_exceptionThe name is too long. Length restrictions may depend on the operating system or configuration.
Remarks
The name may be prefixed with Global\ or Local\ to specify a namespace. When the Global namespace is specified, the synchronization object may be shared with any processes on the system. When the Local namespace is specified, which is also the default when no namespace is specified, the synchronization object may be shared with processes in the same session. On Windows, a session is a login session, and services typically run in a different non-interactive session. On Unix-like operating systems, each shell has its own session. Session-local synchronization objects may be appropriate for synchronizing between processes with a parent/child relationship where they all run in the same session.
If a name is provided and a synchronization object of the requested type already exists in the namespace, the existing synchronization object is opened. If a synchronization object of a different type already exists in the namespace, a xtd::threading::wait_handle_cannot_be_opened_exception is thrown. Otherwise, a new synchronization object is created.
If a system event with the name specified for the name parameter already exists, the initialState parameter is ignored.
Warning
When using this constructor for named system events, specify false for initial_state. This constructor provides no way to determine whether a named system event was created, so you cannot make any assumptions about the state of the named event. To determine whether a named event was created, use the xtd::threading::event_wait_handle(bool, xtd::threading::event_reset_mode, xtd::utring, bool) constructor or the xtd::threading::event_wait_handle(bool, xtd::threading::event__reset_mode, xtd:string, bool) constructor.
Remarks
If the initial state of the event is nonsignaled, threads that wait on the event will block. If the initial state is signaled, and the xtd::threading::event_reset_mode::manual_reset flag is specified for mode, threads that wait on the event will not block. If the initial state is signaled, and mode is xtd::threading::event_reset_mode::auto_reset, the first thread that waits on the event will be released immediately, after which the event will reset, and subsequent threads will block.