ComponentSpace Internet Time Class Library Reference

NetworkTimeClient.BeginGetTime Method ()

Initiates an asynchronous get time operation.

[Visual Basic]
Overloads Public Function BeginGetTime() As IAsyncResult
[C#]
public IAsyncResult BeginGetTime();

Return Value

The IAsyncResult that identifies the posted asynchronous request.

Remarks

In asynchronous processing, you use BeginGetTime to raise the GetTimeCompleted event when the time operation has completed.

To use BeginGetTime, create an event handler that processes the results of the asynchronous operation and associate it with your event delegate. BeginGetTime initiates an asynchronous time operation; the NetworkTimeClient is notified, through the raising of the GetTimeCompleted event, when the time operation is completed. The NetworkTimeClient can then access the time by calling EndGetTime.

Note: The BeginGetTime method returns immediately, but the asynchronous operation is not completed until the event handler is called.

Because BeginGetTime is asynchronous, you can call it to get the time without blocking the current thread of execution. To synchronously get the time, use the GetTime method.

Once an asynchronous operation completes, you can call BeginGetTime again in the event handler to keep receiving notifications.

The IAsyncResult that BeginGetTime returns identifies the asynchronous operation that the method call started. You can use this IAsyncResult throughout the lifetime of the operation, although you generally do not use it until EndGetTime is called. However, if you start several asynchronous operations, you can place their IAsyncResult values in an array and specify whether to wait for all operations or any operation to complete. In this case, you use the AsyncWaitHandle property of the IAsyncResult to identify the completed operation.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace | NetworkTimeClient.BeginGetTime Overload List