System.Net.Sockets.SocketAsyncEventArgs.OnCompleted Method

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

Syntax

protected virtual void OnCompleted (SocketAsyncEventArgs e)

Parameters

e
The event that is signaled.

Remarks

This method is not callable by user code. This method gets called by the internals of the System.Net.Sockets.SocketAsyncEventArgs object when the current operation is complete. This method is used with all asynchronous socket (xxxAsync) methods.

An application that creates a class inheriting from System.Net.Sockets.SocketAsyncEventArgs can override this method to hook into this completion notification and clean up any resources that it allocated for the operation. The default implementation just raises the SocketAsyncEventArgs.Completed event.

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 (xxxAsync) methods on the System.Net.Sockets.Socket class.

The caller's SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs) 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 SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs) 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 System.Net.Sockets.SocketAsyncEventArgs object parameter to obtain status of the completed asynchronous socket operation.

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0