HttpClientBeginGetRequestStream Method |
Begins an asynchronous request for a Stream object to use to write data.
Namespace: Crestron.SimplSharp.Net.HttpAssembly: SimplSharpHelperInterface (in SimplSharpHelperInterface.dll) Version: 2.21.121
Syntax
Exceptions
RemarksThe 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