[This is preliminary documentation and is subject to change.]
C# |
public class Sync
All Members | Constructors | Methods | Properties | ||
Icon | Member | Description |
---|---|---|
Sync()()()() |
Creates a new Sync object in the ready state.
| |
Equals(Object) | (Inherited from Object.) | |
Finalize()()()() |
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.) | |
GetHashCode()()()() |
Serves as a hash function for a particular type.
(Inherited from Object.) | |
GetType()()()() |
Gets the Type of the current instance.
(Inherited from Object.) | |
MemberwiseClone()()()() |
Creates a shallow copy of the current Object.
(Inherited from Object.) | |
Reset()()()() | Resets this Sync so that it can be reused.
| |
Signal()()()() | Signals the Sync object. | |
Signal(Object) | Signals this Sync object with a particular object to pass.
| |
TimedOut | Determines if the Sync has timed out after a Wait
call. | |
ToString()()()() | (Inherited from Object.) | |
Wait()()()() | Waits for a signal from this Sync and obtains the
object passed by Signal. | |
Wait(Int32) | Waits for a signal from this Sync for a maximum
period of time and obtains the object passed by Signal. | |
Wait(IEnumerable<(Of <<'(Sync>)>>)) | Waits until all Syncs in a collection have
been signalled. |
To use Sync, simply instantiate one for use by two threads that need to synchronise. One thread calls Wait and the other calls Signal. The waiting thread will not proceed until Signal is called. The two calls can be made in either order. If Signal is called before Wait, Sync is very fast, and no Monitor calls are made.
The Sync can be reused by calling Reset()()()(). It is up to the caller to ensure in this case that both threads know about the reset - this is particularly important if the Sync has timed out.
You can optionally pass an object from the signalling thread to the waiting thread by passing it as an parameter to Signal. The object will be returned from the Wait call. You can also optionally set a timeout on the Wait call.
Object | |
Sync |