Click or drag to resize

HttpClientBeginGetRequestStream Method

Begins an asynchronous request for a Stream object to use to write data.

Namespace: Crestron.SimplSharp.Net.Http
Assembly: SimplSharpHelperInterface (in SimplSharpHelperInterface.dll) Version: 2.21.121
Syntax
C#
public HttpClientDISPATCHASYNC_ERROR BeginGetRequestStream(
	HTTPStreamRequestCallbackEx callback,
	HttpClientRequest aRequest,
	Object user
)

Parameters

callback  HTTPStreamRequestCallbackEx
The HTTPStreamRequestCallbackEx delegate
aRequest  HttpClientRequest
The state object for this request
user  Object
User defined status object

Return Value

HttpClientDISPATCHASYNC_ERROR
updated request
Exceptions
ExceptionCondition
HttpExceptionInvalid operation
ArgumentNullExceptionaRequest is NULL
InvalidOperationExceptionRequest must be in new request state
NotSupportedExceptionSSL (HTTPS) is not supported
Remarks
The BeginGetRequestStream method requires some synchronous setup tasks to complete (DNS resolution, proxy detection, and TCP socket connection, for example) before this method becomes asynchronous. As a result, this method should never be called on a user interface (UI) thread because it might take considerable time (up to several minutes depending on network settings) to complete the initial synchronous setup tasks before an exception for an error is thrown or the method succeeds.
Example
// Open an HTTP client HttpClient client = new HttpClient(); // Make a CEevent to wait on. StreamAsync_Test allDone = new StreamAsync_Test(); allDone.wait_for_response.Reset(); // Create a new HttpRequest object. HttpRequest request = new HttpRequest("http://www.contoso.com/example.aspx"); request.ContentType = "application/x-www-form-urlencoded"; // Set the Method property to 'POST' to post data to the URI. request.Method = "POST"; // start the asynchronous operation request.BeginGetRequestStream(new HTTPStreamRequestCallbackEx(GetRequestStreamCallback), request, (object)allDone); // Keep the main thread from continuing while the asynchronous // operation completes. A real world application // could do something useful such as updating its user interface. if (allDone.wait_for_response.Wait(30000)) ErrorLog.Notice("Received response"); else ErrorLog.Notice("No response");

Version Information

.NET

Supported in: 6.0

.NET Compact Framework

Supported in: 3.5
See Also