C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
AnalyzeRe.Utilities.AsyncRequestMonitor< T > Class Template Referencesealed

Can be used to asynchronously poll a request until the result is ready. More...

Classes

class  OnCompletedEventArgs
 The OnPollEventHandler EventArgs. More...
 
class  OnErrorEventArgs
 The OnPollEventHandler EventArgs. More...
 
class  OnPollEventArgs
 The OnPollEventHandler EventArgs. More...
 

Public Member Functions

 AsyncRequestMonitor (Func< T > functionThatMight503, PollingOptions pollingOptions=null)
 Prepare this request monitor to executes the specified delegate request until it completes.
 
 AsyncRequestMonitor (T resourceToMonitor, PollingOptions pollingOptions=null)
 Prepare this request monitor to monitor the specified resource until it completes.
 
void Dispose ()
 Cancel the polling thread if running and dispose.
 
delegate void OnCompletedEventHandler (object sender, OnCompletedEventArgs e)
 The request has returned with a successful code.
 
delegate void OnErrorEventHandler (object sender, OnErrorEventArgs e)
 A request has failed in an unexpected way.
 
delegate void OnPollEventHandler (object sender, OnPollEventArgs e)
 A request has returned with a 503 code and RetryAfter header.
 
void Start ()
 Begin polling the delegate asynchronously.
 
void Stop ()
 Cancel any pending requests and stop polling.
 
T Wait ()
 Join the polling thread and block further execution until the results is available to be returned on an error arises.
 

Properties

TimeSpan Elapsed [get]
 The time taken between the first request and when polling ceased (either due to success or error). Includes the time taken executing any callbacks such as OnSuccess and OnError.
 
bool IsPollingActive [get]
 Returns true if a thread is actively polling this delegate.
 
PollingOptions PollingOptions [get, set]
 Controls the polling behaviour (how frequently the function is polled and for how long). Can only be changed while stopped.
 
T Result [get]
 The result of the delegate after successfully returning.
 
Exception ResultException [get]
 The error encountered in retrieving the result (if any).
 

Events

OnCompletedEventHandler OnCompleted
 Event fired when the request has returned with a successful code.
 
OnErrorEventHandler OnError
 Event fired when a request has failed in an unexpected way.
 
OnPollEventHandler OnPoll
 Event fired when a request has returned with a 503 code and RetryAfter header.
 

Detailed Description

Can be used to asynchronously poll a request until the result is ready.

Definition at line 13 of file AsyncRequestMonitor.cs.

Inheritance diagram for AnalyzeRe.Utilities.AsyncRequestMonitor< T >:

Constructor & Destructor Documentation

◆ AsyncRequestMonitor() [1/2]

AnalyzeRe.Utilities.AsyncRequestMonitor< T >.AsyncRequestMonitor ( Func< T functionThatMight503,
PollingOptions  pollingOptions = null 
)
inline

Prepare this request monitor to executes the specified delegate request until it completes.

Parameters
functionThatMight503A delegate function that returns the value you want but might also throw a 503 exception.
pollingOptionsControls the polling behaviour (how frequently the function is polled and for how long)

Definition at line 142 of file AsyncRequestMonitor.cs.

◆ AsyncRequestMonitor() [2/2]

AnalyzeRe.Utilities.AsyncRequestMonitor< T >.AsyncRequestMonitor ( T  resourceToMonitor,
PollingOptions  pollingOptions = null 
)
inline

Prepare this request monitor to monitor the specified resource until it completes.

Parameters
resourceToMonitorA IStoredAPIResource_WithStatus resource whose status should be monitored until it is ready.
pollingOptionsControls the polling behaviour (how frequently the function is polled and for how long)

Definition at line 155 of file AsyncRequestMonitor.cs.

Member Function Documentation

◆ Dispose()

Cancel the polling thread if running and dispose.

Definition at line 169 of file AsyncRequestMonitor.cs.

◆ OnCompletedEventHandler()

delegate void AnalyzeRe.Utilities.AsyncRequestMonitor< T >.OnCompletedEventHandler ( object  sender,
OnCompletedEventArgs  e 
)

The request has returned with a successful code.

Parameters
senderThe AsyncRequestMonitor firing the event.
eThe OnCompletedEventHandler event args.

◆ OnErrorEventHandler()

delegate void AnalyzeRe.Utilities.AsyncRequestMonitor< T >.OnErrorEventHandler ( object  sender,
OnErrorEventArgs  e 
)

A request has failed in an unexpected way.

Parameters
senderThe AsyncRequestMonitor firing the event.
eThe OnErrorEventHandler event args.

◆ OnPollEventHandler()

delegate void AnalyzeRe.Utilities.AsyncRequestMonitor< T >.OnPollEventHandler ( object  sender,
OnPollEventArgs  e 
)

A request has returned with a 503 code and RetryAfter header.

Parameters
senderThe AsyncRequestMonitor firing the event.
eThe polling event args.

◆ Start()

Begin polling the delegate asynchronously.

Definition at line 193 of file AsyncRequestMonitor.cs.

◆ Stop()

Cancel any pending requests and stop polling.

Definition at line 234 of file AsyncRequestMonitor.cs.

◆ Wait()

Join the polling thread and block further execution until the results is available to be returned on an error arises.

Returns
The request result, once the asynchronous success has completed.
Exceptions
AggregateExceptionIf the asynchronous success fails.

Definition at line 247 of file AsyncRequestMonitor.cs.

Property Documentation

◆ Elapsed

The time taken between the first request and when polling ceased (either due to success or error). Includes the time taken executing any callbacks such as OnSuccess and OnError.

Definition at line 32 of file AsyncRequestMonitor.cs.

◆ IsPollingActive

Returns true if a thread is actively polling this delegate.

Definition at line 21 of file AsyncRequestMonitor.cs.

◆ PollingOptions

Controls the polling behaviour (how frequently the function is polled and for how long). Can only be changed while stopped.

Definition at line 18 of file AsyncRequestMonitor.cs.

◆ Result

The result of the delegate after successfully returning.

Definition at line 24 of file AsyncRequestMonitor.cs.

◆ ResultException

Exception AnalyzeRe.Utilities.AsyncRequestMonitor< T >.ResultException
get

The error encountered in retrieving the result (if any).

Definition at line 27 of file AsyncRequestMonitor.cs.

Event Documentation

◆ OnCompleted

Event fired when the request has returned with a successful code.

Definition at line 69 of file AsyncRequestMonitor.cs.

◆ OnError

Event fired when a request has failed in an unexpected way.

Definition at line 131 of file AsyncRequestMonitor.cs.

◆ OnPoll

Event fired when a request has returned with a 503 code and RetryAfter header.

Definition at line 99 of file AsyncRequestMonitor.cs.


The documentation for this class was generated from the following file: