ComponentSpace ICMP Class Library Reference

IcmpClient.BeginReceive Method ()

Initiates an asynchronous receive operation.

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

Return Value

The IAsyncResult that identifies the posted asynchronous request.

Remarks

In asynchronous processing, you use BeginReceive to raise the ReceiveCompleted event when the receive operation has completed.

To use BeginReceive, create an event handler that processes the results of the asynchronous operation and associate it with your event delegate. BeginReceive initiates an asynchronous receive operation; the IcmpClient is notified, through the raising of the ReceiveCompleted event, when the receive operation is completed. The IcmpClient can then access the receive status by calling EndReceive.

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

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

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

The IAsyncResult that BeginReceive 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 EndReceive 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

IcmpClient Class | ComponentSpace.Icmp Namespace | IcmpClient.BeginReceive Overload List