SocketAsyncEventArgs.OnCompleted Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents a method that is called when an asynchronous operation completes.

Namespace:  System.Net.Sockets
Assembly:  System.Net (in System.Net.dll)

Syntax

'Declaration
Protected Overridable Sub OnCompleted ( _
    e As SocketAsyncEventArgs _
)
protected virtual void OnCompleted(
    SocketAsyncEventArgs e
)

Parameters

Remarks

This method is used to hook up an event handler to be used as the completion callback for a subsequent asynchronous socket operation. The caller must implement at least one callback delegate inherited from this method prior to starting an asynchronous socket operation using one of the asynchronous methods on the System.Net.Sockets.Socket class: Socket.ConnectAsync, Socket.ReceiveAsync, and Socket.SendAsync.

The caller's OnCompleted method provides a way for client applications to complete an asynchronous socket operation. A callback delegate must be implemented when an asynchronous socket operation is initiated. The completion callback delegate(s) inherited from the OnCompleted method must contain program logic to finish processing the asynchronous socket operation for the client.

When an asynchronous operation is signaled, the application uses the SocketAsyncEventArgs object parameter to obtain status of the completed asynchronous socket operation.

This method is used with all asynchronous socket methods: Socket.ConnectAsync, Socket.ReceiveAsync, and Socket.SendAsync.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.