System.Net.HttpListener.BeginGetContext Method

Begins asynchronously retrieving an incoming request.

Syntax

public IAsyncResult BeginGetContext (AsyncCallback callback, object state)

Parameters

callback
An AsyncCallback delegate that references the method to invoke when a client request is available.
state
A user-defined object that contains information about the operation. This object is passed to the callback delegate when the operation completes.

Returns

An IAsyncResult object that indicates the status of the asynchronous operation.

Remarks

The HttpListener.BeginGetContext(AsyncCallback, object) method begins an asynchronous (non-blocking) call to receive incoming client requests. Before calling this method, you must call the HttpListener.Start method and add at least one Uniform Resource Identifier (URI) prefix to listen for by adding the URI strings to the System.Net.HttpListenerPrefixCollection returned by the HttpListener.Prefixes property.

The asynchronous operation must be completed by calling the HttpListener.EndGetContext(IAsyncResult) method. Typically, the method is invoked by the callback delegate.

This method does not block while the operation completes. To get an incoming request and block until the operation completes, call the HttpListener.GetContext method.

For detailed information about using the asynchronous programming model, see Asynchronous Programming Overview

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0