ComponentSpace DNS Class Library Reference

DnsClient.BeginLookup Method (String)

Initiates an asynchronous lookup operation.

[Visual Basic]
Overloads Public Function BeginLookup( _
   ByVal hostName As String _
) As IAsyncResult
[C#]
public IAsyncResult BeginLookup(
   string hostName
);

Parameters

hostName
The host name to resolve.

Return Value

The IAsyncResult that identifies the posted asynchronous request.

Remarks

In asynchronous processing, you use BeginLookup to raise the LookupCompleted event when the lookup operation has completed.

To use BeginLookup, create an event handler that processes the results of the asynchronous operation and associate it with your event delegate. BeginLookup initiates an asynchronous lookup operation; the DnsClient is notified, through the raising of the LookupCompleted event, when the lookup operation is completed. The DnsClient can then access the lookup status by calling EndLookup.

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

Because BeginLookup is asynchronous, you can call it to receive the lookup status without blocking the current thread of execution. To synchronously lookup, use the Lookup method.

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

The IAsyncResult that BeginLookup 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 EndLookup 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

DnsClient Class | ComponentSpace.Dns Namespace | DnsClient.BeginLookup Overload List