Class SyncObject
Provides a synchronization object that encapsulates thread synchronization mechanisms using Monitor.
public class SyncObject
- Inheritance
-
SyncObject
- Inherited Members
- Extension Methods
Constructors
SyncObject()
public SyncObject()
Methods
Enter()
Enters the synchronization block, waiting indefinitely until the lock is acquired.
public void Enter()
Exit()
Exits the synchronization block.
public void Exit()
Pulse()
Sends a pulse to a single waiting thread.
public void Pulse()
Pulse(object)
Sends a pulse to a single waiting thread and sets the optional state.
public void Pulse(object state)
Parameters
state
objectAn optional state object to pass along with the pulse.
PulseAll()
Sends a pulse to all waiting threads.
public void PulseAll()
PulseAll(object)
Sends a pulse to all waiting threads and sets the optional state.
public void PulseAll(object state)
Parameters
state
objectAn optional state object to pass along with the pulse.
PulseSignal(object)
Signals a waiting thread by sending a pulse along with setting the processed flag.
public void PulseSignal(object state = null)
Parameters
state
objectAn optional state object to pass along with the pulse.
TryEnter(TimeSpan?)
Attempts to enter the synchronization block, with an optional timeout.
public bool TryEnter(TimeSpan? timeOut = null)
Parameters
timeOut
TimeSpan?The timeout duration. If null, the method does not specify a timeout.
Returns
- bool
true if the synchronization lock was successfully acquired; otherwise, false.
Wait(TimeSpan?)
Waits for a pulse with an optional timeout.
public bool Wait(TimeSpan? timeOut = null)
Parameters
timeOut
TimeSpan?The timeout duration. If null, waits indefinitely.
Returns
- bool
true if the pulse was received; otherwise, false (in case of timeout).
WaitSignal(TimeSpan?)
Waits for a signal with an optional timeout.
public bool WaitSignal(TimeSpan? timeOut = null)
Parameters
timeOut
TimeSpan?The timeout duration. If null, waits indefinitely.
Returns
- bool
true if the signal was received; otherwise, false (in case of timeout).
WaitSignal(TimeSpan?, out object)
Waits for a signal with an optional timeout and outputs the state associated with the signal.
public bool WaitSignal(TimeSpan? timeOut, out object state)
Parameters
timeOut
TimeSpan?The timeout duration. If null, waits indefinitely.
state
objectThe state object passed by the signaling call.
Returns
- bool
true if a signal was received; otherwise, false (in case of timeout).