Struct Timeout
Helps to compute timeout for asynchronous operations.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public readonly struct Timeout
Constructors
| Edit this page View SourceTimeout(TimeSpan)
Constructs a new timeout control object.
Declaration
public Timeout(TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | Max duration of operation. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Timeout(TimeSpan, Timestamp)
Constructs a new timeout control object.
Declaration
public Timeout(TimeSpan timeout, Timestamp startedAt)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | Max duration of operation. |
Timestamp | startedAt | The point in time when operation was started. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Timeout(TimeSpan, TimeProvider)
Constructs a new timeout control object.
Declaration
public Timeout(TimeSpan timeout, TimeProvider provider)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeout | Max duration of operation. |
TimeProvider | provider | Time provider. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Fields
| Edit this page View SourceInfiniteTicks
Represents a number of ticks in InfiniteTimeSpan.
Declaration
public const long InfiniteTicks = -10000
Field Value
Type | Description |
---|---|
long |
MaxTimeoutParameterTicks
Represents maximum possible timeout value, in ticks, that can be passed to some methods such as Delay(TimeSpan) or CancelAfter(TimeSpan).
Declaration
public const long MaxTimeoutParameterTicks = 21474836470000
Field Value
Type | Description |
---|---|
long |
Properties
| Edit this page View SourceExpired
Gets expired timeout.
Declaration
public static Timeout Expired { get; }
Property Value
Type | Description |
---|---|
Timeout |
Infinite
Gets infinite timeout.
Declaration
public static Timeout Infinite { get; }
Property Value
Type | Description |
---|---|
Timeout |
IsExpired
Indicates that timeout is occurred.
Declaration
public bool IsExpired { get; }
Property Value
Type | Description |
---|---|
bool |
IsInfinite
Determines whether this timeout is infinite.
Declaration
public bool IsInfinite { get; }
Property Value
Type | Description |
---|---|
bool |
Value
Gets value of this timeout.
Declaration
public TimeSpan Value { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
Methods
| Edit this page View SourceThrowIfExpired()
Throws TimeoutException if timeout occurs.
Declaration
public void ThrowIfExpired()
Exceptions
Type | Condition |
---|---|
TimeoutException | Timeout occurred. |
ThrowIfExpired(TimeProvider)
Throws TimeoutException if timeout occurs.
Declaration
public void ThrowIfExpired(TimeProvider provider)
Parameters
Type | Name | Description |
---|---|---|
TimeProvider | provider |
Exceptions
Type | Condition |
---|---|
TimeoutException | Timeout occurred. |
ThrowIfExpired(TimeProvider, out TimeSpan)
Throws TimeoutException if timeout occurs.
Declaration
public void ThrowIfExpired(TimeProvider provider, out TimeSpan remainingTime)
Parameters
Type | Name | Description |
---|---|---|
TimeProvider | provider | Time provider. |
TimeSpan | remainingTime | The remaining time before timeout. |
Exceptions
Type | Condition |
---|---|
TimeoutException | Timeout occurred. |
ThrowIfExpired(out TimeSpan)
Throws TimeoutException if timeout occurs.
Declaration
public void ThrowIfExpired(out TimeSpan remainingTime)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | remainingTime | The remaining time before timeout. |
Exceptions
Type | Condition |
---|---|
TimeoutException | Timeout occurred. |
TryGetRemainingTime(TimeProvider, out TimeSpan)
Gets the remaining time.
Declaration
public bool TryGetRemainingTime(TimeProvider provider, out TimeSpan remainingTime)
Parameters
Type | Name | Description |
---|---|---|
TimeProvider | provider | Time provider. |
TimeSpan | remainingTime | The remaining time before timeout. |
Returns
Type | Description |
---|---|
bool |
TryGetRemainingTime(out TimeSpan)
Gets the remaining time.
Declaration
public bool TryGetRemainingTime(out TimeSpan remainingTime)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | remainingTime | The remaining time before timeout. |
Returns
Type | Description |
---|---|
bool |
Operators
| Edit this page View Sourceoperator false(in Timeout)
Indicates that timeout is not reached.
Declaration
public static bool operator false(in Timeout timeout)
Parameters
Type | Name | Description |
---|---|---|
Timeout | timeout | Timeout control object. |
Returns
Type | Description |
---|---|
bool |
implicit operator TimeSpan(in Timeout)
Extracts original timeout value from this object.
Declaration
public static implicit operator TimeSpan(in Timeout timeout)
Parameters
Type | Name | Description |
---|---|---|
Timeout | timeout | Timeout control object. |
Returns
Type | Description |
---|---|
TimeSpan | The original timeout value. |
operator true(in Timeout)
Indicates that timeout is reached.
Declaration
public static bool operator true(in Timeout timeout)
Parameters
Type | Name | Description |
---|---|---|
Timeout | timeout | Timeout control object. |
Returns
Type | Description |
---|---|
bool |