本文整理汇总了C#中TimeOutState类的典型用法代码示例。如果您正苦于以下问题:C# TimeOutState类的具体用法?C# TimeOutState怎么用?C# TimeOutState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeOutState类属于命名空间,在下文中一共展示了TimeOutState类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ParseWebException
public RestResponse ParseWebException(WebException exc, TimeOutState timeoutstate)
{
var restresponse = new RestResponse();
// Check to see if this is an HTTP error or a transport error.
// In cases where an HTTP error occurs ( status code >= 400 )
// return the underlying HTTP response, otherwise assume a
// transport exception (ex: connection timeout) and
// rethrow the exception
if (exc.Response is HttpWebResponse)
{
var errorresponse = exc.Response as HttpWebResponse;
restresponse = ExtractResponse(errorresponse);
}
else
{
restresponse.ErrorException = exc;
restresponse.ErrorMessage = exc.Message;
if (timeoutstate != null && exc.Status == WebExceptionStatus.RequestCanceled)
{
restresponse.ResponseStatus = timeoutstate.TimedOut ? ResponseStatus.TimedOut : ResponseStatus.Aborted;
}
else
{
restresponse.ResponseStatus = ResponseStatus.Error;
}
}
return restresponse;
}
开发者ID:mrockmann,项目名称:twilio-dotnet,代码行数:31,代码来源:HttpWebRequestWrapper.cs
示例2: GetStyleMethodInternalAsync
private void GetStyleMethodInternalAsync(string method, Action<HttpResponse> callback)
{
try
{
var url = Url;
var webRequest = ConfigureAsyncWebRequest(method, url);
timeoutState = new TimeOutState { Request = webRequest };
var asyncResult = webRequest.BeginGetResponse(result => ResponseCallback(result, callback), webRequest);
SetTimeout(asyncResult, webRequest, timeoutState);
}
catch (Exception ex)
{
var response = new HttpResponse();
response.ErrorMessage = ex.Message;
response.ErrorException = ex;
response.ResponseStatus = ResponseStatus.Error;
ExecuteCallback(response, callback);
}
}
开发者ID:MikeWarriner,项目名称:UrbanAirship.NET,代码行数:19,代码来源:Http.Async.cs
示例3: GetStyleMethodInternalAsync
private HttpWebRequest GetStyleMethodInternalAsync(string method, Action<HttpResponse> callback)
{
HttpWebRequest webRequest = null;
try
{
var url = Url;
webRequest = ConfigureAsyncWebRequest(method, url);
if (HasBody && (method == "DELETE" || method == "OPTIONS"))
{
webRequest.ContentType = RequestContentType;
WriteRequestBodyAsync(webRequest, callback);
}
else
{
_timeoutState = new TimeOutState { Request = webRequest };
var asyncResult = webRequest.BeginGetResponse(result => ResponseCallback(result, callback), webRequest);
SetTimeout(asyncResult, _timeoutState);
}
}
catch(Exception ex)
{
ExecuteCallback(CreateErrorResponse(ex), callback);
}
return webRequest;
}
开发者ID:BLesnau,项目名称:PixelPrinter,代码行数:25,代码来源:Http.Async.cs
示例4: SetTimeout
private void SetTimeout(IAsyncResult asyncResult, TimeOutState timeOutState)
{
if (Timeout != 0)
{
ThreadPool.RegisterWaitForSingleObject(asyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), timeOutState, Timeout, true);
}
}
开发者ID:BLesnau,项目名称:PixelPrinter,代码行数:7,代码来源:Http.Async.cs
示例5: WriteRequestBodyAsync
private void WriteRequestBodyAsync(HttpWebRequest webRequest, Action<HttpResponse> callback)
{
IAsyncResult asyncResult;
_timeoutState = new TimeOutState { Request = webRequest };
if (HasBody || HasFiles || AlwaysMultipartFormData)
{
webRequest.ContentLength = CalculateContentLength();
asyncResult = webRequest.BeginGetRequestStream(result => RequestStreamCallback(result, callback), webRequest);
}
else
{
asyncResult = webRequest.BeginGetResponse(r => ResponseCallback(r, callback), webRequest);
}
SetTimeout(asyncResult, _timeoutState);
}
开发者ID:BLesnau,项目名称:PixelPrinter,代码行数:18,代码来源:Http.Async.cs
示例6: SetTimeout
private void SetTimeout(IAsyncResult asyncResult, TimeOutState timeOutState)
{
#if FRAMEWORK && !PocketPC
if (Timeout != 0)
{
ThreadPool.RegisterWaitForSingleObject(asyncResult.AsyncWaitHandle,
TimeoutCallback, timeOutState, Timeout, true);
}
#endif
}
开发者ID:jenistonj,项目名称:RestSharp,代码行数:10,代码来源:Http.Async.cs
示例7: SetTimeout
private void SetTimeout(IAsyncResult asyncResult, HttpWebRequest request, TimeOutState timeOutState)
{
#if FRAMEWORK
if (Timeout != 0)
{
ThreadPool.RegisterWaitForSingleObject(asyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), timeOutState, Timeout, true);
}
#endif
}
开发者ID:MikeWarriner,项目名称:UrbanAirship.NET,代码行数:9,代码来源:Http.Async.cs
示例8: WriteRequestBodyAsync
private void WriteRequestBodyAsync(HttpWebRequest webRequest, Action<HttpResponse> callback)
{
IAsyncResult asyncResult;
timeoutState = new TimeOutState { Request = webRequest };
if (HasBody || HasFiles || HasBytes)
{
#if !WINDOWS_PHONE
webRequest.ContentLength = CalculateContentLength();
#endif
asyncResult = webRequest.BeginGetRequestStream(result => RequestStreamCallback(result, callback), webRequest);
}
else
{
asyncResult = webRequest.BeginGetResponse(r => ResponseCallback(r, callback), webRequest);
}
SetTimeout(asyncResult, webRequest, timeoutState);
}
开发者ID:MikeWarriner,项目名称:UrbanAirship.NET,代码行数:20,代码来源:Http.Async.cs
示例9: GetStyleMethodInternalAsync
private HttpWebRequest GetStyleMethodInternalAsync(string method, Action<HttpResponse> callback)
{
HttpWebRequest webRequest = null;
try
{
var url = Url;
webRequest = ConfigureAsyncWebRequest(method, url);
_timeoutState = new TimeOutState { Request = webRequest };
var asyncResult = webRequest.BeginGetResponse(result => ResponseCallback(result, callback), webRequest);
SetTimeout(asyncResult, _timeoutState);
}
catch(Exception ex)
{
ExecuteCallback(CreateErrorResponse(ex), callback);
}
return webRequest;
}
开发者ID:topas,项目名称:RestSharp,代码行数:17,代码来源:Http.Async.cs
示例10: WriteRequestBodyAsync
private void WriteRequestBodyAsync(HttpWebRequest webRequest, Action<HttpResponse> callback)
{
IAsyncResult asyncResult;
this.timeoutState = new TimeOutState { Request = webRequest };
if (this.HasBody || this.HasFiles || this.AlwaysMultipartFormData)
{
#if !WINDOWS_PHONE
webRequest.ContentLength = this.CalculateContentLength();
#endif
asyncResult = webRequest.BeginGetRequestStream(
result => this.RequestStreamCallback(result, callback), webRequest);
}
else
{
asyncResult = webRequest.BeginGetResponse(r => this.ResponseCallback(r, callback), webRequest);
}
this.SetTimeout(asyncResult, this.timeoutState);
}
开发者ID:eamonwoortman,项目名称:RestSharp.Unity,代码行数:20,代码来源:Http.Async.cs
示例11: WriteRequestBodyAsync
private void WriteRequestBodyAsync(HttpWebRequest webRequest, Action<HttpResponse> callback)
{
IAsyncResult asyncResult;
_timeoutState = new TimeOutState { Request = webRequest };
if (HasBody || HasFiles)
{
asyncResult = webRequest.BeginGetRequestStream(result => RequestStreamCallback(result, callback), webRequest);
}
else
{
asyncResult = webRequest.BeginGetResponse(r => ResponseCallback(r, callback), webRequest);
}
SetTimeout(asyncResult, _timeoutState);
}
开发者ID:oiseger,项目名称:geoserver-csharp,代码行数:17,代码来源:Http.Async.cs
示例12: GetStyleMethodInternalAsync
private HttpWebRequest GetStyleMethodInternalAsync(string method, Action<HttpResponse> callback, object userState)
{
HttpWebRequest webRequest = null;
try
{
var url = Url;
webRequest = ConfigureAsyncWebRequest(method, url);
_timeoutState = new TimeOutState { Request = webRequest };
var asyncResult = webRequest.BeginGetResponse(result => ResponseCallback(result, callback, userState), webRequest);
SetTimeout(asyncResult, _timeoutState);
}
catch(Exception ex)
{
var response = new HttpResponse();
response.ErrorMessage = ex.Message;
response.ErrorException = ex;
response.ResponseStatus = ResponseStatus.Error;
response.UserState = userState;
ExecuteCallback(response, callback);
}
return webRequest;
}
开发者ID:SPARTAN563,项目名称:RestSharp,代码行数:22,代码来源:Http.Async.cs
注:本文中的TimeOutState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论