15 #region Public Properties
33 #endregion Public Properties
35 #region Private Properties
47 private Thread _pollingThread;
48 #endregion Private Properties
70 #endregion OnCompleted
74 [
Obsolete(
"Polling status updates are currently unavailable.")]
93 [
Obsolete(
"Polling status updates are currently unavailable.")]
98 [
Obsolete(
"Polling status updates are currently unavailable.")]
101 [
Obsolete(
"Polling status updates are currently unavailable.")]
145 _resourceToMonitor =
null;
159 "the IStoredAPIResource_WithStatus interface.");
160 _functionToPoll =
null;
164 #endregion Constructors
172 GC.SuppressFinalize(
this);
189 #endregion Destructor
191 #region Public Methods
196 throw new Exception(
"A request is already being monitored.");
199 _cancellation?.Dispose();
217 if (_functionToPoll !=
null)
220 else if (_resourceToMonitor !=
null)
230 _pollingThread.Start();
236 _cancellation?.Cancel();
237 _pollingThread?.Join();
238 _pollingThread =
null;
239 _cancellation?.Dispose();
240 _cancellation =
null;
249 _pollingThread?.Join();
255 #endregion Public Methods
257 #region Async Polling
270 OnError?.Invoke(
this,
new OnErrorEventArgs(
e,
e.ServerError,
e.RestResponse));
275 OnError?.Invoke(
this,
new OnErrorEventArgs(
e,
null,
null));
281 _pollingThread =
null;
282 _cancellation?.Dispose();
283 _cancellation =
null;
286 #endregion Async Polling
A custom exception class that includes the RestSharp.IRestResponse that generated the exception,...
Describes a collection of resources which can be listed.
Used to deserialize server error messages.
API methods / requests made available to the user.
Determines the behaviour of the API when automatically retrying a request whose result is not yet rea...
CancellationToken? CancellationToken
A cancellation token (if available) supplied to the polling method to allow the polling task to be ca...
int MaxPollTotalTime
The maximum time (in milliseconds) to poll the request before raising a NotWaitingException....
int MaxPollInterval
The maximum time (in milliseconds) to wait between retrying the request. (Default is a maximum of 10 ...
int MinPollInterval
The minimum time (in milliseconds) to wait between retrying the request. (Default is no minimum time....
double BackoffRate
The rate at which the polling interval is increased after repeated attempts. The interval will not be...
The OnPollEventHandler EventArgs.
T ReturnValue
The return value of the delegate.
OnCompletedEventArgs(T returnValue)
Create a new OnCompletedEventArgs.
The OnPollEventHandler EventArgs.
IRestResponse Response
The IRestResponse received (if any).
OnErrorEventArgs(Exception ex, ServerError serverError, IRestResponse response)
Create a new OnErrorEventArgs.
Exception Exception
The exception encountered (if any).
The OnPollEventHandler EventArgs.
IRestResponse Response
The IRestResponse received.
OnPollEventArgs(double retryAfterSeconds, IRestResponse restResponse)
Create a new OnPollEventArgs.
double RetryAfter
The RetryAfter header value.
Can be used to asynchronously poll a request until the result is ready.
delegate void OnErrorEventHandler(object sender, OnErrorEventArgs e)
A request has failed in an unexpected way.
delegate void OnCompletedEventHandler(object sender, OnCompletedEventArgs e)
The request has returned with a successful code.
OnPollEventHandler OnPoll
Event fired when a request has returned with a 503 code and RetryAfter header.
OnErrorEventHandler OnError
Event fired when a request has failed in an unexpected way.
void Start()
Begin polling the delegate asynchronously.
OnCompletedEventHandler OnCompleted
Event fired when the request has returned with a successful code.
delegate void OnPollEventHandler(object sender, OnPollEventArgs e)
A request has returned with a 503 code and RetryAfter header.
bool IsPollingActive
Returns true if a thread is actively polling this delegate.
PollingOptions PollingOptions
Controls the polling behaviour (how frequently the function is polled and for how long)....
AsyncRequestMonitor(T resourceToMonitor, PollingOptions pollingOptions=null)
Prepare this request monitor to monitor the specified resource until it completes.
T Result
The result of the delegate after successfully returning.
void Stop()
Cancel any pending requests and stop polling.
void Dispose()
Cancel the polling thread if running and dispose.
Exception ResultException
The error encountered in retrieving the result (if any).
AsyncRequestMonitor(Func< T > functionThatMight503, PollingOptions pollingOptions=null)
Prepare this request monitor to executes the specified delegate request until it completes.
TimeSpan Elapsed
The time taken between the first request and when polling ceased (either due to success or error)....
T Wait()
Join the polling thread and block further execution until the results is available to be returned on ...
Describes an APIResource class that has a "status" property and corresponding "status_message" which ...