Initiates an asynchronous echo operation that has a specified state object.
The IAsyncResult that identifies the posted asynchronous request.
In asynchronous processing, you use BeginEcho to raise the EchoCompleted event when the echo 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 BeginEcho, create an event handler that processes the results of the asynchronous operation and associate it with your event delegate. BeginEcho initiates an asynchronous echo operation; the EchoClient is notified, through the raising of the EchoCompleted event, when the echo operation is completed. The EchoClient can then access the echo status by calling EndEcho.
Note: The BeginEcho method returns immediately, but the asynchronous operation is not completed until the event handler is called.
Because BeginEcho is asynchronous, you can call it to receive the echo status without blocking the current thread of execution. To synchronously echo, use the Echo method.
Once an asynchronous operation completes, you can call BeginEcho again in the event handler to keep receiving notifications.
The IAsyncResult that BeginEcho returns indentifies 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 EndEcho 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 BeginEcho 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.
EchoClient Class | ComponentSpace.Icmp Namespace | EchoClient.BeginEcho Overload List