ComponentSpace.InternetTime

ComponentSpace Internet Time Class Library Reference

ComponentSpace.InternetTime Namespace

The ComponentSpace.InternetTime namespace contains classes that implement various Internet time protocols.

Namespace hierarchy

Classes

Class | Description
DaytimeClient | Implementation of the Daytime Protocol (RFC-867).
GetTimeCompletedEventArgs | Provides data for the GetTimeCompleted event.
InternetTimeException | The exception that is thrown when a time operation fails.
NetworkTimeClient | Implementation of the Network Time Protocol (RFC-1305/RFC-2030).
TimeClient | Implementation of the Time Protocol (RFC-868).

Delegates

Delegate | Description
GetTimeCompletedEventHandler | Represents the method that will handle the GetTimeCompleted/> event.


DaytimeClient Class

Implementation of the Daytime Protocol (RFC-867).

For a list of all members of this type, see DaytimeClient Members.

System.Object
ComponentSpace.InternetTime.DaytimeClient

[Visual Basic]
Public Class DaytimeClient
[C#]
public class DaytimeClient

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The DaytimeClient constructor specifies the address of the server. Optionally, the ReceiveTimeout may be set. The time request may be sent and the reply received synchronously (blocking) using GetTime, or asynchronously (non-blocking) using BeginGetTime and EndGetTime.

Requirements

Namespace: ComponentSpace.InternetTime

Assembly: ComponentSpace.InternetTime (in ComponentSpace.InternetTime.dll)

See Also

DaytimeClient Members | ComponentSpace.InternetTime Namespace


DaytimeClient Members

DaytimeClient overview

Public Instance Constructors

DaytimeClient Overloaded. Initializes a new instance of the DaytimeClient class.

Public Instance Properties

ReceiveTimeout | Gets or sets the number of milliseconds to wait for the response from the server.
SynchronizingObject | Gets or sets the synchonizing object for receiving events.

Public Instance Methods

BeginGetTime | Overloaded. Initiates an asynchronous get time operation.
EndGetTime | Completes the specified asynchronous get time operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetTime | Gets the time from the server.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Public Instance Events

GetTimeCompleted Occurs when the time operation has completed.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


DaytimeClient Constructor

Initializes a new instance of the DaytimeClient class with the specified server address. The address can either be the name of the server (eg. tick.usno.navy.mil) or its IP address (eg. 192.5.41.40).

Overload List

Initializes a new instance of the DaytimeClient class with the specified server IP address.

public DaytimeClient(IPAddress);

Initializes a new instance of the DaytimeClient class with the specified server IP address.

public DaytimeClient(IPEndPoint);

Initializes a new instance of the DaytimeClient class with the specified server address. The address can either be the name of the server (eg. tick.usno.navy.mil) or its IP address (eg. 192.5.41.40).

public DaytimeClient(string);

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


DaytimeClient Constructor (String)

Initializes a new instance of the DaytimeClient class with the specified server address. The address can either be the name of the server (eg. tick.usno.navy.mil) or its IP address (eg. 192.5.41.40).

[Visual Basic]
Overloads Public Sub New( _
ByVal serverAddress As String _
)
[C#]
public DaytimeClient(
string serverAddress
);

Parameters

serverAddress
The server address (eg. 192.5.41.40 or tick.usno.navy.mil).

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace | DaytimeClient Constructor Overload List


DaytimeClient Constructor (IPAddress)

Initializes a new instance of the DaytimeClient class with the specified server IP address.

[Visual Basic]
Overloads Public Sub New( _
ByVal serverAddress As IPAddress _
)
[C#]
public DaytimeClient(
IPAddress serverAddress
);

Parameters

serverAddress
The server IP address.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace | DaytimeClient Constructor Overload List


DaytimeClient Constructor (IPEndPoint)

Initializes a new instance of the DaytimeClient class with the specified server IP address.

[Visual Basic]
Overloads Public Sub New( _
ByVal serverAddress As IPEndPoint _
)
[C#]
public DaytimeClient(
IPEndPoint serverAddress
);

Parameters

serverAddress
The server IP address.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace | DaytimeClient Constructor Overload List


DaytimeClient Properties

The properties of the DaytimeClient class are listed below. For a complete list of DaytimeClient class members, see the DaytimeClient Members topic.

Public Instance Properties

ReceiveTimeout | Gets or sets the number of milliseconds to wait for the response from the server.
SynchronizingObject | Gets or sets the synchonizing object for receiving events.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


DaytimeClient.ReceiveTimeout Property

Gets or sets the number of milliseconds to wait for the response from the server.

[Visual Basic]
Public Property ReceiveTimeout As Integer
[C#]
public int ReceiveTimeout {get; set;}

Property Value

The number of milliseconds to wait for the response from the server. The default is 5 seconds.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


DaytimeClient.SynchronizingObject Property

Gets or sets the synchonizing object for receiving events.

[Visual Basic]
Public Property SynchronizingObject As ISynchronizeInvoke
[C#]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject {get; set;}

Property Value

An ISynchronizeInvoke, which represents the object that marshals the event-handler call resulting from a GetTimeCompleted event. The default is a null reference (Nothing in Visual Basic).

Remarks

A GetTimeCompleted event results from a BeginGetTime request to a specific thread. Typically, the SynchronizingObject is set when it's used within a form, because forms are bound to a specific thread.

Typically, the synchronizing object marshals a method call into a single thread.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


DaytimeClient Methods

The methods of the DaytimeClient class are listed below. For a complete list of DaytimeClient class members, see the DaytimeClient Members topic.

Public Instance Methods

BeginGetTime | Overloaded. Initiates an asynchronous get time operation.
EndGetTime | Completes the specified asynchronous get time operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetTime | Gets the time from the server.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


BeginGetTime Method

ComponentSpace Internet Time Class Library Reference

DaytimeClient.BeginGetTime Method

Initiates an asynchronous get time operation.

Overload List

Initiates an asynchronous get time operation.

public IAsyncResult BeginGetTime();

Initiates an asynchronous get time operation that has a specified state object.

public IAsyncResult BeginGetTime(object);

Initiates an asynchronous get time operation that has a specified state object. This overload receives notification, through a callback, of the identity of the event handler for this operation.

public IAsyncResult BeginGetTime(object,AsyncCallback);

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


DaytimeClient.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 DaytimeClient is notified, through the raising of the GetTimeCompleted event, when the time operation is completed. The DaytimeClient 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

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


DaytimeClient.BeginGetTime Method (Object)

Initiates an asynchronous get time operation that has a specified state object.

[Visual Basic]
Overloads Public Function BeginGetTime( _
ByVal stateObject As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginGetTime(
object stateObject
);

Parameters

stateObject
A state object, specified by the application, that contains information associated with the asynchronous operation.

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.

Use this overload to associate information with the operation that will be preserved throughout the operation's lifetime. The event handler can detect this information by looking at the AsyncState of the IAsyncResult that is associated with the operation.

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 DaytimeClient is notified, through the raising of the GetTimeCompleted event, when the time operation is completed. The DaytimeClient 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 receive 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.

The state object associates state information with the operation. For example, if you call BeginGetTime multiple times to initiate multiple operations, you can identify each operation through a separate state object that you define.

You can also use the state object to pass information across process threads. If a thread is started but the callback is on a different thread in an asynchronous scenario, the state object is marshaled and passed back along with information from the event.

See Also

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


DaytimeClient.BeginGetTime Method (Object, AsyncCallback)

Initiates an asynchronous get time operation that has a specified state object. This overload receives notification, through a callback, of the identity of the event handler for this operation.

[Visual Basic]
Overloads Public Function BeginGetTime( _
ByVal stateObject As Object, _
ByVal asyncCallback As AsyncCallback _
) As IAsyncResult
[C#]
public IAsyncResult BeginGetTime(
object stateObject,
AsyncCallback asyncCallback
);

Parameters

stateObject
A state object, specified by the application, that contains information associated with the asynchronous operation.
asyncCallback
The AsyncCallback that will receive the notification of the asynchronous operation completion.

Return Value

The IAsyncResult that identifies the posted asynchronous request.

Remarks

When you use this overload, the callback specified in the callback parameter is invoked directly when the time operation has completed; the GetTimeCompleted event is not raised. The other overloads of BeginGetTime rely on this component to raise the GetTimeCompleted event.

To use BeginGetTime, define an asynchronous callback method. BeginGetTime initiates an asynchronous time operation; the DaytimeClient is notified, through a call to the callback method, when the time operation is completed. The DaytimeClient can then access the time status by calling EndGetTime.

Use this overload to associate information with the operation that will be preserved throughout the operation's lifetime. The event handler can detect this information by looking at the AsyncState of the IAsyncResult that is associated with the operation.

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 receive the time status without blocking the current thread of execution. To synchronously 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.

The state object associates state information with the operation. For example, if you call BeginGetTime multiple times to initiate multiple operations, you can identify each operation through a separate state object that you define.

You can also use the state object to pass information across process threads. If a thread is started but the callback is on a different thread in an asynchronous scenario, the state object is marshaled and passed back along with information from the event.

See Also

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


DaytimeClient.EndGetTime Method

Completes the specified asynchronous get time operation.

[Visual Basic]
Public Function EndGetTime( _
ByVal asyncResult As IAsyncResult _
) As String
[C#]
public string EndGetTime(
IAsyncResult asyncResult
);

Parameters

asyncResult
The IAsyncResult that identifies the asynchronous time operation to finish, and from which to retrieve an end result.

Return Value

The time.

Remarks

When the GetTimeCompleted event is raised, EndGetTime completes the operation that was initiated by the BeginGetTime call.

Exceptions

Exception Type | Condition
InternetTimeException | Thrown when the time cannot be received.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


DaytimeClient.GetTime Method

Gets the time from the server.

[Visual Basic]
Public Function GetTime() As String
[C#]
public string GetTime();

Return Value

The time.

Exceptions

Exception Type | Condition
InternetTimeException | Thrown when the time cannot be received.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


DaytimeClient Events

The events of the DaytimeClient class are listed below. For a complete list of DaytimeClient class members, see the DaytimeClient Members topic.

Public Instance Events

GetTimeCompleted Occurs when the time operation has completed.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


DaytimeClient.GetTimeCompleted Event

Occurs when the time operation has completed.

[Visual Basic]
Public Event GetTimeCompleted As GetTimeCompletedEventHandler
[C#]
public event GetTimeCompletedEventHandler GetTimeCompleted;

Event Data

The event handler receives an argument of type GetTimeCompletedEventArgs containing data related to this event. The following GetTimeCompletedEventArgs property provides information specific to this event.

Property | Description
AsyncResult | Gets the result of the asynchronous time operation.

Remarks

BeginGetTime is used in asynchronous processing to raise the GetTimeCompleted event when the time operation has completed.

EndGetTime is used to complete the operation initiated by a call to BeginGetTime and get the time status when the GetTimeCompleted event is raised.

See Also

DaytimeClient Class | ComponentSpace.InternetTime Namespace


GetTimeCompletedEventArgs Class

Provides data for the GetTimeCompleted event.

For a list of all members of this type, see GetTimeCompletedEventArgs Members.

System.Object
System.EventArgs
ComponentSpace.InternetTime.GetTimeCompletedEventArgs

[Visual Basic]
Public Class GetTimeCompletedEventArgs
Inherits EventArgs
[C#]
public class GetTimeCompletedEventArgs : EventArgs

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The GetTimeCompleted event is raised by the DaytimeClient, NetworkTimeClient and TimeClient. It contains all the information needed to complete the asynchronous time operation.

Requirements

Namespace: ComponentSpace.InternetTime

Assembly: ComponentSpace.InternetTime (in ComponentSpace.InternetTime.dll)

See Also

GetTimeCompletedEventArgs Members | ComponentSpace.InternetTime Namespace


GetTimeCompletedEventArgs Members

GetTimeCompletedEventArgs overview

Public Instance Properties

AsyncResult Gets the result of the asynchronous time operation.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

GetTimeCompletedEventArgs Class | ComponentSpace.InternetTime Namespace


GetTimeCompletedEventArgs Properties

The properties of the GetTimeCompletedEventArgs class are listed below. For a complete list of GetTimeCompletedEventArgs class members, see the GetTimeCompletedEventArgs Members topic.

Public Instance Properties

AsyncResult Gets the result of the asynchronous time operation.

See Also

GetTimeCompletedEventArgs Class | ComponentSpace.InternetTime Namespace


GetTimeCompletedEventArgs.AsyncResult Property

Gets the result of the asynchronous time operation.

[Visual Basic]
Public ReadOnly Property AsyncResult As IAsyncResult
[C#]
public System.IAsyncResult AsyncResult {get;}

Property Value

An IAsyncResult that contains the data associated with the time operation.

Remarks

AsyncResult identifies ongoing or completed asynchronous operations. The property contains data that helps determine which of several potential asynchronous operations to complete, and when passed to the event handler, enables EndGetTime to get the time associated with the completed operation.

See Also

GetTimeCompletedEventArgs Class | ComponentSpace.InternetTime Namespace


GetTimeCompletedEventHandler Delegate

Represents the method that will handle the GetTimeCompleted/> event.

[Visual Basic]
Public Delegate Sub GetTimeCompletedEventHandler( _
ByVal sender As Object, _
ByVal e As GetTimeCompletedEventArgs _
)
[C#]
public delegate void GetTimeCompletedEventHandler(
object sender,
GetTimeCompletedEventArgs e
);

Parameters

sender
The source of the event.
e
A GetTimeCompletedEventArgs that contains the event data.

Remarks

When you create a GetTimeCompletedEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.

Requirements

Namespace: ComponentSpace.InternetTime

Assembly: ComponentSpace.InternetTime (in ComponentSpace.InternetTime.dll)

See Also

ComponentSpace.InternetTime Namespace


InternetTimeException Class

The exception that is thrown when a time operation fails.

For a list of all members of this type, see InternetTimeException Members.

System.Object
System.Exception
System.ApplicationException
ComponentSpace.InternetTime.InternetTimeException

[Visual Basic]
Public Class InternetTimeException
Inherits ApplicationException
[C#]
public class InternetTimeException : ApplicationException

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: ComponentSpace.InternetTime

Assembly: ComponentSpace.InternetTime (in ComponentSpace.InternetTime.dll)

See Also

InternetTimeException Members | ComponentSpace.InternetTime Namespace


InternetTimeException Members

InternetTimeException overview

Public Instance Properties

HelpLink (inherited from Exception) | Gets or sets a link to the help file associated with this exception.
InnerException (inherited from Exception) | Gets the Exception instance that caused the current exception.
Message (inherited from Exception) | Gets a message that describes the current exception.
Source (inherited from Exception) | Gets or sets the name of the application or the object that causes the error.
StackTrace (inherited from Exception) | Gets a string representation of the frames on the call stack at the time the current exception was thrown.
TargetSite (inherited from Exception) | Gets the method that throws the current exception.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBaseException (inherited from Exception) | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetObjectData (inherited from Exception) | When overridden in a derived class, sets the SerializationInfo with information about the exception.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Exception) | Creates and returns a string representation of the current exception.

Protected Instance Properties

HResult (inherited from Exception) Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

InternetTimeException Class | ComponentSpace.InternetTime Namespace


NetworkTimeClient Class

Implementation of the Network Time Protocol (RFC-1305/RFC-2030).

For a list of all members of this type, see NetworkTimeClient Members.

System.Object
ComponentSpace.InternetTime.NetworkTimeClient

[Visual Basic]
Public Class NetworkTimeClient
[C#]
public class NetworkTimeClient

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The NetworkTimeClient constructor specifies the address of the server. Optionally, the ReceiveTimeout may be set. The time request may be sent and the reply received synchronously (blocking) using GetTime, or asynchronously (non-blocking) using BeginGetTime and EndGetTime.

Requirements

Namespace: ComponentSpace.InternetTime

Assembly: ComponentSpace.InternetTime (in ComponentSpace.InternetTime.dll)

See Also

NetworkTimeClient Members | ComponentSpace.InternetTime Namespace


NetworkTimeClient Members

NetworkTimeClient overview

Public Instance Constructors

NetworkTimeClient Overloaded. Initializes a new instance of the NetworkTimeClient class.

Public Instance Properties

ReceiveTimeout | Gets or sets the number of milliseconds to wait for the response from the server.
SynchronizingObject | Gets or sets the synchonizing object for receiving events.

Public Instance Methods

BeginGetTime | Overloaded. Initiates an asynchronous get time operation.
EndGetTime | Completes the specified asynchronous get time operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetTime | Gets the time from the server.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Public Instance Events

GetTimeCompleted Occurs when the time operation has completed.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


NetworkTimeClient Constructor

Initializes a new instance of the NetworkTimeClient class with the specified server address. The address can either be the name of the server (eg. tick.usno.navy.mil) or its IP address (eg. 192.5.41.40).

Overload List

Initializes a new instance of the NetworkTimeClient class with the specified server IP address.

public NetworkTimeClient(IPAddress);

Initializes a new instance of the NetworkTimeClient class with the specified server IP address.

public NetworkTimeClient(IPEndPoint);

Initializes a new instance of the NetworkTimeClient class with the specified server address. The address can either be the name of the server (eg. tick.usno.navy.mil) or its IP address (eg. 192.5.41.40).

public NetworkTimeClient(string);

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


NetworkTimeClient Constructor (String)

Initializes a new instance of the NetworkTimeClient class with the specified server address. The address can either be the name of the server (eg. tick.usno.navy.mil) or its IP address (eg. 192.5.41.40).

[Visual Basic]
Overloads Public Sub New( _
ByVal serverAddress As String _
)
[C#]
public NetworkTimeClient(
string serverAddress
);

Parameters

serverAddress
The server address (eg. 192.5.41.40 or tick.usno.navy.mil).

See Also

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


NetworkTimeClient Constructor (IPAddress)

Initializes a new instance of the NetworkTimeClient class with the specified server IP address.

[Visual Basic]
Overloads Public Sub New( _
ByVal serverAddress As IPAddress _
)
[C#]
public NetworkTimeClient(
IPAddress serverAddress
);

Parameters

serverAddress
The server IP address.

See Also

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


NetworkTimeClient Constructor (IPEndPoint)

Initializes a new instance of the NetworkTimeClient class with the specified server IP address.

[Visual Basic]
Overloads Public Sub New( _
ByVal serverAddress As IPEndPoint _
)
[C#]
public NetworkTimeClient(
IPEndPoint serverAddress
);

Parameters

serverAddress
The server IP address.

See Also

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


NetworkTimeClient Properties

The properties of the NetworkTimeClient class are listed below. For a complete list of NetworkTimeClient class members, see the NetworkTimeClient Members topic.

Public Instance Properties

ReceiveTimeout | Gets or sets the number of milliseconds to wait for the response from the server.
SynchronizingObject | Gets or sets the synchonizing object for receiving events.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


NetworkTimeClient.ReceiveTimeout Property

Gets or sets the number of milliseconds to wait for the response from the server.

[Visual Basic]
Public Property ReceiveTimeout As Integer
[C#]
public int ReceiveTimeout {get; set;}

Property Value

The number of milliseconds to wait for the response from the server. The default is 5 seconds.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


NetworkTimeClient.SynchronizingObject Property

Gets or sets the synchonizing object for receiving events.

[Visual Basic]
Public Property SynchronizingObject As ISynchronizeInvoke
[C#]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject {get; set;}

Property Value

An ISynchronizeInvoke, which represents the object that marshals the event-handler call resulting from a GetTimeCompleted event. The default is a null reference (Nothing in Visual Basic).

Remarks

A GetTimeCompleted event results from a BeginGetTime request to a specific thread. Typically, the SynchronizingObject is set when it's used within a form, because forms are bound to a specific thread.

Typically, the synchronizing object marshals a method call into a single thread.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


NetworkTimeClient Methods

The methods of the NetworkTimeClient class are listed below. For a complete list of NetworkTimeClient class members, see the NetworkTimeClient Members topic.

Public Instance Methods

BeginGetTime | Overloaded. Initiates an asynchronous get time operation.
EndGetTime | Completes the specified asynchronous get time operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetTime | Gets the time from the server.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


BeginGetTime Method

ComponentSpace Internet Time Class Library Reference

NetworkTimeClient.BeginGetTime Method

Initiates an asynchronous get time operation.

Overload List

Initiates an asynchronous get time operation.

public IAsyncResult BeginGetTime();

Initiates an asynchronous get time operation that has a specified state object.

public IAsyncResult BeginGetTime(object);

Initiates an asynchronous get time operation that has a specified state object. This overload receives notification, through a callback, of the identity of the event handler for this operation.

public IAsyncResult BeginGetTime(object,AsyncCallback);

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


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


NetworkTimeClient.BeginGetTime Method (Object)

Initiates an asynchronous get time operation that has a specified state object.

[Visual Basic]
Overloads Public Function BeginGetTime( _
ByVal stateObject As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginGetTime(
object stateObject
);

Parameters

stateObject
A state object, specified by the application, that contains information associated with the asynchronous operation.

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.

Use this overload to associate information with the operation that will be preserved throughout the operation's lifetime. The event handler can detect this information by looking at the AsyncState of the IAsyncResult that is associated with the operation.

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 receive 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.

The state object associates state information with the operation. For example, if you call BeginGetTime multiple times to initiate multiple operations, you can identify each operation through a separate state object that you define.

You can also use the state object to pass information across process threads. If a thread is started but the callback is on a different thread in an asynchronous scenario, the state object is marshaled and passed back along with information from the event.

See Also

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


NetworkTimeClient.BeginGetTime Method (Object, AsyncCallback)

Initiates an asynchronous get time operation that has a specified state object. This overload receives notification, through a callback, of the identity of the event handler for this operation.

[Visual Basic]
Overloads Public Function BeginGetTime( _
ByVal stateObject As Object, _
ByVal asyncCallback As AsyncCallback _
) As IAsyncResult
[C#]
public IAsyncResult BeginGetTime(
object stateObject,
AsyncCallback asyncCallback
);

Parameters

stateObject
A state object, specified by the application, that contains information associated with the asynchronous operation.
asyncCallback
The AsyncCallback that will receive the notification of the asynchronous operation completion.

Return Value

The IAsyncResult that identifies the posted asynchronous request.

Remarks

When you use this overload, the callback specified in the callback parameter is invoked directly when the time operation has completed; the GetTimeCompleted event is not raised. The other overloads of BeginGetTime rely on this component to raise the GetTimeCompleted event.

To use BeginGetTime, define an asynchronous callback method. BeginGetTime initiates an asynchronous time operation; the NetworkTimeClient is notified, through a call to the callback method, when the time operation is completed. The NetworkTimeClient can then access the time status by calling EndGetTime.

Use this overload to associate information with the operation that will be preserved throughout the operation's lifetime. The event handler can detect this information by looking at the AsyncState of the IAsyncResult that is associated with the operation.

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 receive the time status without blocking the current thread of execution. To synchronously 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.

The state object associates state information with the operation. For example, if you call BeginGetTime multiple times to initiate multiple operations, you can identify each operation through a separate state object that you define.

You can also use the state object to pass information across process threads. If a thread is started but the callback is on a different thread in an asynchronous scenario, the state object is marshaled and passed back along with information from the event.

See Also

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


NetworkTimeClient.EndGetTime Method

Completes the specified asynchronous get time operation.

[Visual Basic]
Public Function EndGetTime( _
ByVal asyncResult As IAsyncResult _
) As Date
[C#]
public DateTime EndGetTime(
IAsyncResult asyncResult
);

Parameters

asyncResult
The IAsyncResult that identifies the asynchronous time operation to finish, and from which to retrieve an end result.

Return Value

The time.

Remarks

When the GetTimeCompleted event is raised, EndGetTime completes the operation that was initiated by the BeginGetTime call.

Exceptions

Exception Type | Condition
InternetTimeException | Thrown when the time cannot be received.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


NetworkTimeClient.GetTime Method

Gets the time from the server.

[Visual Basic]
Public Function GetTime() As Date
[C#]
public DateTime GetTime();

Return Value

The time.

Exceptions

Exception Type | Condition
InternetTimeException | Thrown when the time cannot be received.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


NetworkTimeClient Events

The events of the NetworkTimeClient class are listed below. For a complete list of NetworkTimeClient class members, see the NetworkTimeClient Members topic.

Public Instance Events

GetTimeCompleted Occurs when the time operation has completed.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


NetworkTimeClient.GetTimeCompleted Event

Occurs when the time operation has completed.

[Visual Basic]
Public Event GetTimeCompleted As GetTimeCompletedEventHandler
[C#]
public event GetTimeCompletedEventHandler GetTimeCompleted;

Event Data

The event handler receives an argument of type GetTimeCompletedEventArgs containing data related to this event. The following GetTimeCompletedEventArgs property provides information specific to this event.

Property | Description
AsyncResult | Gets the result of the asynchronous time operation.

Remarks

BeginGetTime is used in asynchronous processing to raise the GetTimeCompleted event when the time operation has completed.

EndGetTime is used to complete the operation initiated by a call to BeginGetTime and get the time status when the GetTimeCompleted event is raised.

See Also

NetworkTimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient Class

Implementation of the Time Protocol (RFC-868).

For a list of all members of this type, see TimeClient Members.

System.Object
ComponentSpace.InternetTime.TimeClient

[Visual Basic]
Public Class TimeClient
[C#]
public class TimeClient

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The TimeClient constructor specifies the address of the server. Optionally, the ReceiveTimeout may be set. The time request may be sent and the reply received synchronously (blocking) using GetTime, or asynchronously (non-blocking) using BeginGetTime and EndGetTime.

Requirements

Namespace: ComponentSpace.InternetTime

Assembly: ComponentSpace.InternetTime (in ComponentSpace.InternetTime.dll)

See Also

TimeClient Members | ComponentSpace.InternetTime Namespace


TimeClient Members

TimeClient overview

Public Instance Constructors

TimeClient Overloaded. Initializes a new instance of the TimeClient class.

Public Instance Properties

ReceiveTimeout | Gets or sets the number of milliseconds to wait for the response from the server.
SynchronizingObject | Gets or sets the synchonizing object for receiving events.

Public Instance Methods

BeginGetTime | Overloaded. Initiates an asynchronous get time operation.
EndGetTime | Completes the specified asynchronous get time operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetTime | Gets the time from the server.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Public Instance Events

GetTimeCompleted Occurs when the time operation has completed.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient Constructor

Initializes a new instance of the TimeClient class with the specified server address. The address can either be the name of the server (eg. tick.usno.navy.mil) or its IP address (eg. 192.5.41.40).

Overload List

Initializes a new instance of the TimeClient class with the specified server IP address.

public TimeClient(IPAddress);

Initializes a new instance of the TimeClient class with the specified server IP address.

public TimeClient(IPEndPoint);

Initializes a new instance of the TimeClient class with the specified server address. The address can either be the name of the server (eg. tick.usno.navy.mil) or its IP address (eg. 192.5.41.40).

public TimeClient(string);

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient Constructor (String)

Initializes a new instance of the TimeClient class with the specified server address. The address can either be the name of the server (eg. tick.usno.navy.mil) or its IP address (eg. 192.5.41.40).

[Visual Basic]
Overloads Public Sub New( _
ByVal serverAddress As String _
)
[C#]
public TimeClient(
string serverAddress
);

Parameters

serverAddress
The server address (eg. 192.5.41.40 or tick.usno.navy.mil).

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace | TimeClient Constructor Overload List


TimeClient Constructor (IPAddress)

Initializes a new instance of the TimeClient class with the specified server IP address.

[Visual Basic]
Overloads Public Sub New( _
ByVal serverAddress As IPAddress _
)
[C#]
public TimeClient(
IPAddress serverAddress
);

Parameters

serverAddress
The server IP address.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace | TimeClient Constructor Overload List


TimeClient Constructor (IPEndPoint)

Initializes a new instance of the TimeClient class with the specified server IP address.

[Visual Basic]
Overloads Public Sub New( _
ByVal serverAddress As IPEndPoint _
)
[C#]
public TimeClient(
IPEndPoint serverAddress
);

Parameters

serverAddress
The server IP address.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace | TimeClient Constructor Overload List


TimeClient Properties

The properties of the TimeClient class are listed below. For a complete list of TimeClient class members, see the TimeClient Members topic.

Public Instance Properties

ReceiveTimeout | Gets or sets the number of milliseconds to wait for the response from the server.
SynchronizingObject | Gets or sets the synchonizing object for receiving events.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient.ReceiveTimeout Property

Gets or sets the number of milliseconds to wait for the response from the server.

[Visual Basic]
Public Property ReceiveTimeout As Integer
[C#]
public int ReceiveTimeout {get; set;}

Property Value

The number of milliseconds to wait for the response from the server. The default is 5 seconds.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient.SynchronizingObject Property

Gets or sets the synchonizing object for receiving events.

[Visual Basic]
Public Property SynchronizingObject As ISynchronizeInvoke
[C#]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject {get; set;}

Property Value

An ISynchronizeInvoke, which represents the object that marshals the event-handler call resulting from a GetTimeCompleted event. The default is a null reference (Nothing in Visual Basic).

Remarks

A GetTimeCompleted event results from a BeginGetTime request to a specific thread. Typically, the SynchronizingObject is set when it's used within a form, because forms are bound to a specific thread.

Typically, the synchronizing object marshals a method call into a single thread.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient Methods

The methods of the TimeClient class are listed below. For a complete list of TimeClient class members, see the TimeClient Members topic.

Public Instance Methods

BeginGetTime | Overloaded. Initiates an asynchronous get time operation.
EndGetTime | Completes the specified asynchronous get time operation.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetTime | Gets the time from the server.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


BeginGetTime Method

ComponentSpace Internet Time Class Library Reference

TimeClient.BeginGetTime Method

Initiates an asynchronous get time operation.

Overload List

Initiates an asynchronous get time operation.

public IAsyncResult BeginGetTime();

Initiates an asynchronous get time operation that has a specified state object.

public IAsyncResult BeginGetTime(object);

Initiates an asynchronous get time operation that has a specified state object. This overload receives notification, through a callback, of the identity of the event handler for this operation.

public IAsyncResult BeginGetTime(object,AsyncCallback);

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient.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 TimeClient is notified, through the raising of the GetTimeCompleted event, when the time operation is completed. The TimeClient 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

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


TimeClient.BeginGetTime Method (Object)

Initiates an asynchronous get time operation that has a specified state object.

[Visual Basic]
Overloads Public Function BeginGetTime( _
ByVal stateObject As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginGetTime(
object stateObject
);

Parameters

stateObject
A state object, specified by the application, that contains information associated with the asynchronous operation.

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.

Use this overload to associate information with the operation that will be preserved throughout the operation's lifetime. The event handler can detect this information by looking at the AsyncState of the IAsyncResult that is associated with the operation.

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 TimeClient is notified, through the raising of the GetTimeCompleted event, when the time operation is completed. The TimeClient 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 receive 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.

The state object associates state information with the operation. For example, if you call BeginGetTime multiple times to initiate multiple operations, you can identify each operation through a separate state object that you define.

You can also use the state object to pass information across process threads. If a thread is started but the callback is on a different thread in an asynchronous scenario, the state object is marshaled and passed back along with information from the event.

See Also

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


TimeClient.BeginGetTime Method (Object, AsyncCallback)

Initiates an asynchronous get time operation that has a specified state object. This overload receives notification, through a callback, of the identity of the event handler for this operation.

[Visual Basic]
Overloads Public Function BeginGetTime( _
ByVal stateObject As Object, _
ByVal asyncCallback As AsyncCallback _
) As IAsyncResult
[C#]
public IAsyncResult BeginGetTime(
object stateObject,
AsyncCallback asyncCallback
);

Parameters

stateObject
A state object, specified by the application, that contains information associated with the asynchronous operation.
asyncCallback
The AsyncCallback that will receive the notification of the asynchronous operation completion.

Return Value

The IAsyncResult that identifies the posted asynchronous request.

Remarks

When you use this overload, the callback specified in the callback parameter is invoked directly when the time operation has completed; the GetTimeCompleted event is not raised. The other overloads of BeginGetTime rely on this component to raise the GetTimeCompleted event.

To use BeginGetTime, define an asynchronous callback method. BeginGetTime initiates an asynchronous time operation; the TimeClient is notified, through a call to the callback method, when the time operation is completed. The TimeClient can then access the time status by calling EndGetTime.

Use this overload to associate information with the operation that will be preserved throughout the operation's lifetime. The event handler can detect this information by looking at the AsyncState of the IAsyncResult that is associated with the operation.

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 receive the time status without blocking the current thread of execution. To synchronously 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.

The state object associates state information with the operation. For example, if you call BeginGetTime multiple times to initiate multiple operations, you can identify each operation through a separate state object that you define.

You can also use the state object to pass information across process threads. If a thread is started but the callback is on a different thread in an asynchronous scenario, the state object is marshaled and passed back along with information from the event.

See Also

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


TimeClient.EndGetTime Method

Completes the specified asynchronous get time operation.

[Visual Basic]
Public Function EndGetTime( _
ByVal asyncResult As IAsyncResult _
) As Date
[C#]
public DateTime EndGetTime(
IAsyncResult asyncResult
);

Parameters

asyncResult
The IAsyncResult that identifies the asynchronous time operation to finish, and from which to retrieve an end result.

Return Value

The time.

Remarks

When the GetTimeCompleted event is raised, EndGetTime completes the operation that was initiated by the BeginGetTime call.

Exceptions

Exception Type | Condition
InternetTimeException | Thrown when the time cannot be received.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient.GetTime Method

Gets the time from the server.

[Visual Basic]
Public Function GetTime() As Date
[C#]
public DateTime GetTime();

Return Value

The time.

Exceptions

Exception Type | Condition
InternetTimeException | Thrown when the time cannot be received.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient Events

The events of the TimeClient class are listed below. For a complete list of TimeClient class members, see the TimeClient Members topic.

Public Instance Events

GetTimeCompleted Occurs when the time operation has completed.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


TimeClient.GetTimeCompleted Event

Occurs when the time operation has completed.

[Visual Basic]
Public Event GetTimeCompleted As GetTimeCompletedEventHandler
[C#]
public event GetTimeCompletedEventHandler GetTimeCompleted;

Event Data

The event handler receives an argument of type GetTimeCompletedEventArgs containing data related to this event. The following GetTimeCompletedEventArgs property provides information specific to this event.

Property | Description
AsyncResult | Gets the result of the asynchronous time operation.

Remarks

BeginGetTime is used in asynchronous processing to raise the GetTimeCompleted event when the time operation has completed.

EndGetTime is used to complete the operation initiated by a call to BeginGetTime and get the time status when the GetTimeCompleted event is raised.

See Also

TimeClient Class | ComponentSpace.InternetTime Namespace


ComponentSpace.InternetTimeHierarchy

ComponentSpace Internet Time Class Library Reference

ComponentSpace.InternetTime Hierarchy

System.Object
ComponentSpace.InternetTime.DaytimeClient
ComponentSpace.InternetTime.NetworkTimeClient
ComponentSpace.InternetTime.TimeClient
System.Delegate ---- System.ICloneable, System.Runtime.Serialization.ISerializable
System.MulticastDelegate
ComponentSpace.InternetTime.GetTimeCompletedEventHandler
System.EventArgs
ComponentSpace.InternetTime.GetTimeCompletedEventArgs
System.Exception ---- System.Runtime.Serialization.ISerializable
System.ApplicationException
ComponentSpace.InternetTime.InternetTimeException

See Also

ComponentSpace.InternetTime Namespace