Table of Contents

Struct TimeoutHelper

Namespace
Arc4u
Assembly
Arc4u.dll

Measures a timeout from the moment it is created and provides helpers to compute with time spans where MaxValue means "infinite".

public readonly struct TimeoutHelper
Inherited Members

Constructors

TimeoutHelper(TimeSpan)

Define a period of time.

public TimeoutHelper(TimeSpan timeout)

Parameters

timeout TimeSpan

The period.

Properties

OriginalTimeout

Get the period defined.

public TimeSpan OriginalTimeout { get; }

Property Value

TimeSpan

Methods

Add(DateTime, TimeSpan)

Add to the DateTime the TimeSpan.

public static DateTime Add(DateTime time, TimeSpan timeout)

Parameters

time DateTime

The DateTime

timeout TimeSpan

The period.

Returns

DateTime

The sum.

Add(TimeSpan, TimeSpan)

Get the sum of 2 TimeSpan.

public static TimeSpan Add(TimeSpan timeout1, TimeSpan timeout2)

Parameters

timeout1 TimeSpan

First TimeSpan

timeout2 TimeSpan

Second TimeSpan

Returns

TimeSpan

TimeSpan1 + TimeSpan2.

Divide(TimeSpan, int)

Divide the period by the factor.

public static TimeSpan Divide(TimeSpan timeout, int factor)

Parameters

timeout TimeSpan

The period.

factor int

The factor.

Returns

TimeSpan

The period / the factor.

FromMilliseconds(int)

Compute a TimeSpan from an integer but gives infinite value if equal to -1.

public static TimeSpan FromMilliseconds(int milliseconds)

Parameters

milliseconds int

period.

Returns

TimeSpan

The computed TimeSpan.

FromMilliseconds(uint)

Compute a TimeSpan from an unsigned integer but gives infinite value if equal to MaxValue.

public static TimeSpan FromMilliseconds(uint milliseconds)

Parameters

milliseconds uint

period.

Returns

TimeSpan

The computed TimeSpan.

RemainingTime()

Get the time remaining from since the object is instantiated.

public TimeSpan RemainingTime()

Returns

TimeSpan

SetTimer(TimerCallback, object?)

Execute the callback method when the period is elapsed or immediately if the period is aleady elapsed.

public Timer SetTimer(TimerCallback callback, object? state)

Parameters

callback TimerCallback

The method to call.

state object

Additional parameter.

Returns

Timer

Subtract(DateTime, TimeSpan)

Substract from the DateTime the period.

public static DateTime Subtract(DateTime time, TimeSpan timeout)

Parameters

time DateTime

The DateTime

timeout TimeSpan

The period

Returns

DateTime

The substraction.

ToMilliseconds(TimeSpan)

Returns the number of ticks from the TimeSpan in integer..

public static int ToMilliseconds(TimeSpan timeout)

Parameters

timeout TimeSpan

The TimeSpan

Returns

int