
- Charlie Daniels
SyncFlag
SyncFlag Methods
| SyncFlag() | Constructor for the SyncFlag class |
| CheckAccess() | Checks to see if access is available |
| WaitForAccess() | Pauses the thread until access to the synchronization flag is obtained |
| RaiseFlag() | Sets the status of the sync flag to "raised", granting access to a waiting thread |
| ClearFlag() | Clears the status of the sync flag |
Derived Classes
None
See Also
Class Hierarchy, SyncLock, Thread
public method SyncFlag(bool InitAccess = false)
Parameters
InitAccess
Gets access at creation time if true, in other words the "synchronization flag" is raised. False by default.
Return Value
None
Description
Constructor for the SyncFlag class. If the InitAccess flag is false, the thread which wait for access to the sync flag will wait until another thread "raises the flag".
SyncFlag Class
public virtual method<bool> CheckAccess()
Parameters
None
Return Value
Returns true if access to the resource is currently available, and false if not.
Description
Checks the current status of the synchronization flag. If is "raised", this method returns true. If the sync flag is not currently raised, then this method returns false.
SyncFlag Class
public virtual method<bool> WaitForAccess(int TimeOut = 0)
Parameters
TimeOut
Value of timeout period in milliseconds. If access has not been obtained by that time, the call terminates. If the timeout period is set to zero, the timeout period is infinite.
Return Value
Returns true if access to the resource was obtained, and false if the call times out.
Description
Waits for the synchronization flag to be raised. If it is "raised" when the method is called, the call returns immediately with a return value of true, and the thread can continue its processing. If the sync flag is not raised. then the calling thread waits until another thread raises the sync flag. If the time out value is greater than zero, and access is not obtained in the specified time period, this method returns false.
The thread's execution status is still considered "running" while this method waits for the flag to be raised.
The status of the synchronization flag is automatically turned off once the calling thread is granted access.
SyncFlag Class
public method RaiseFlag()
Parameters
None
Return Value
None
Description
Set the state of the synchronization flag to "raised". If another thread is waiting for access to this sync flag, it will be allowed to proceed. Once that thread gets access to the sync flag, and it continues execution, the state of the sync flag is automatically turned back off. If multiple threads are waiting for access to the thread, this "raise" operation will only release a single waiting thread.
SyncFlag Class
public method ClearFlag()
Parameters
None
Return Value
None
Description
Clears the state of the synchronization flag (removes the "raised" state). This call is normally not needed, since the system turns off the flag automatically when a thread gets access to the flag using "WaitForAccess()".
SyncFlag Class