private void Start(int waitTimeout, int retryCount) { if (RetryProvider == null) { RetryProvider = new RetryProvider(); RetryProvider.PerRetryFailed += PerRetryFailed; RetryProvider.Completed += Completed; RetryProvider.Cancelled += Cancelled; RetryProvider.PerRetryBegin += PerRetryBegin; RetryProvider.PerRetryEnd += PerRetryEnd; RetryProvider.ProgressChanged += ProgressChanged; } if (RetryProvider.IsBusy) { return; } btnStart.Enabled = false; if (lbRecord.Items.Count > 0) { AddMsg(null); } RetryProvider.StartAsyncFunc(ThrowExceptionMethod, waitTimeout * 1000, retryCount); }
/// <summary> /// Send retriable DELETE request to the specified parameters as an asynchronous operation. /// </summary> /// <param name="requestUri">The Uri the request is sent to.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <param name="tryCount">Max try count if SuccessStatusCode equal to false</param> /// <param name="interval">Interval between calls in millisecond</param> /// <returns>The task object representing the asynchronous operation.</returns> public static async Task <HttpResponseMessage> RetryDeleteAsync(this HttpClient httpClient, Uri requestUri, CancellationToken cancellationToken, int tryCount, int interval = 0) { return(await RetryProvider.Retry (async() => await httpClient.DeleteAsync(requestUri, cancellationToken), tryCount, interval)); }
/// <summary> /// Send retriable DELETE request to the specified parameters as an asynchronous operation. /// </summary> /// <param name="requestUri">The Uri the request is sent to.</param> /// <param name="tryCount">Max try count if SuccessStatusCode equal to false</param> /// <param name="interval">Interval between calls in millisecond</param> /// <returns>The task object representing the asynchronous operation.</returns> public static async Task <HttpResponseMessage> RetryDeleteAsync(this HttpClient httpClient, string requestUri, int tryCount, int interval = 0) { return(await RetryProvider.Retry (async() => await httpClient.DeleteAsync(requestUri), tryCount, interval)); }
/// <summary> /// Send retriable PUT request to the specified parameters as an asynchronous operation. /// </summary> /// <param name="requestUri">The Uri the request is sent to.</param> /// <param name="content">The HTTP request content sent to the server.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <param name="tryCount">Max try count if SuccessStatusCode equal to false</param> /// <param name="interval">Interval between calls in millisecond</param> /// <returns>The task object representing the asynchronous operation.</returns> public static async Task <HttpResponseMessage> RetryPutAsync(this HttpClient httpClient, string requestUri, HttpContent content, CancellationToken cancellationToken, int tryCount, int interval = 0) { return(await RetryProvider.Retry (async() => await httpClient.PutAsync(requestUri, content, cancellationToken), tryCount, interval)); }
/// <summary> /// Send retriable PUT request to the specified parameters as an asynchronous operation. /// </summary> /// <param name="requestUri">The Uri the request is sent to.</param> /// <param name="content">The HTTP request content sent to the server.</param> /// <param name="tryCount">Max try count if SuccessStatusCode equal to false</param> /// <param name="interval">Interval between calls in millisecond</param> /// <returns>The task object representing the asynchronous operation.</returns> public static async Task <HttpResponseMessage> RetryPutAsync(this HttpClient httpClient, Uri requestUri, HttpContent content, int tryCount, int interval = 0) { return(await RetryProvider.Retry (async() => await httpClient.PutAsync(requestUri, content), tryCount, interval)); }
/// <summary> /// Send retriable SEND request to the specified parameters as an asynchronous operation. /// </summary> /// <param name="request">Represents a HTTP request message.</param> /// <param name="completionOption">An HTTP completion option value that indicates when the operation should be considered completed.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <param name="tryCount">Max try count if SuccessStatusCode equal to false</param> /// <param name="interval">Interval between calls in millisecond</param> /// <returns>The task object representing the asynchronous operation.</returns> public static async Task <HttpResponseMessage> RetrySendAsync(this HttpClient httpClient, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken, int tryCount, int interval) { return(await RetryProvider.Retry (async() => await httpClient.SendAsync(request, completionOption, cancellationToken), tryCount, interval)); }
/// <summary> /// Send retriable SEND request to the specified parameters as an asynchronous operation. /// </summary> /// <param name="request">Represents a HTTP request message.</param> /// <param name="tryCount">Max try count if SuccessStatusCode equal to false</param> /// <param name="interval">Interval between calls in millisecond</param> /// <returns>The task object representing the asynchronous operation.</returns> public static async Task <HttpResponseMessage> RetrySendAsync(this HttpClient httpClient, HttpRequestMessage request, int tryCount, int interval = 0) { return(await RetryProvider.Retry (async() => await httpClient.SendAsync(request), tryCount, interval)); }
/// <summary> /// Send retriable GET request to the specified parameters as an asynchronous operation. /// </summary> /// <param name="requestUri">The Uri the request is sent to.</param> /// <param name="completionOption">An HTTP completion option value that indicates when the operation should be considered completed.</param> /// <param name="tryCount">Max try count if SuccessStatusCode equal to false</param> /// <param name="interval">Interval between calls in millisecond</param> /// <returns></returns> public static async Task <HttpResponseMessage> RetryGetAsync(this HttpClient httpClient, Uri requestUri, HttpCompletionOption completionOption, int tryCount, int interval = 0) { return(await RetryProvider.Retry (async() => await httpClient.GetAsync(requestUri, completionOption), tryCount, interval)); }