C# Class CSharpAnalytics.Network.BackgroundHttpRequester

Responsible for requesting a queue of URIs over HTTP or HTTPS in background.
Inheritance: IDisposable
Show file Open project: TechSmith/CSharpAnalytics Class Usage Examples

Protected Properties

Property Type Description
NetworkRetryWaitMax System.TimeSpan
NetworkRetryWaitStep System.TimeSpan

Private Properties

Property Type Description
Dispose void
GetNextQueueEntry bool
RequestLoop void
ShouldUsePostForRequest bool

Public Methods

Method Description
Add ( Uri uri ) : void

Add a URI to be requested to the queue.

Dispose ( ) : void
Start ( System.TimeSpan uploadInterval, IEnumerable previouslyUnrequested = null ) : void

Start the BackgroundHttpRequester with a given upload interval and a list of previously unrequested URIs.

StopAsync ( ) : Task>

Stop the BackgroundHttpRequester and return a list of URIs that were not requested.

Protected Methods

Method Description
GetInnermostException ( Exception ex ) : Exception

Obtain the innermost Exception from within an Exception.

RequestWithFailureRetry ( Uri requestUri, CancellationToken cancellationToken ) : void

Request the URI retrying as appropriate if a failure occurs.

WaitBetweenFailedRequests ( System.TimeSpan &previousRetryDelay ) : void

Delay for a period of time between failed network requests.

Private Methods

Method Description
Dispose ( bool isDisposing ) : void
GetNextQueueEntry ( Uri &entry ) : bool

Get the next entry from the queue.

RequestLoop ( ) : void

Loop that keeps requesting URIs in the queue until there are none left, then sleeps.

ShouldUsePostForRequest ( Uri requestUri ) : bool

Whether a URI request is too long to be sent as a GET and instead the query parameters should be sent as the body of a POST instead.

Method Details

Add() public method

Add a URI to be requested to the queue.
public Add ( Uri uri ) : void
uri System.Uri URI to be requested.
return void

Dispose() public method

public Dispose ( ) : void
return void

GetInnermostException() protected static method

Obtain the innermost Exception from within an Exception.
protected static GetInnermostException ( Exception ex ) : Exception
ex System.Exception Exception to obtain the innermost exception from.
return System.Exception

RequestWithFailureRetry() protected abstract method

Request the URI retrying as appropriate if a failure occurs.
protected abstract RequestWithFailureRetry ( Uri requestUri, CancellationToken cancellationToken ) : void
requestUri System.Uri URI to requqest.
cancellationToken System.Threading.CancellationToken
return void

Start() public method

Start the BackgroundHttpRequester with a given upload interval and a list of previously unrequested URIs.
public Start ( System.TimeSpan uploadInterval, IEnumerable previouslyUnrequested = null ) : void
uploadInterval System.TimeSpan How often to send the contents of the queue.
previouslyUnrequested IEnumerable List of previously unrequested URIs obtained last time the requester was stopped.
return void

StopAsync() public method

Stop the BackgroundHttpRequester and return a list of URIs that were not requested.
public StopAsync ( ) : Task>
return Task>

WaitBetweenFailedRequests() protected method

Delay for a period of time between failed network requests.
protected WaitBetweenFailedRequests ( System.TimeSpan &previousRetryDelay ) : void
previousRetryDelay System.TimeSpan Previous retry delay value to base delay on.
return void

Property Details

NetworkRetryWaitMax protected static property

protected static TimeSpan,System NetworkRetryWaitMax
return System.TimeSpan

NetworkRetryWaitStep protected static property

protected static TimeSpan,System NetworkRetryWaitStep
return System.TimeSpan