Class TimedScope
Makes a code block timed (take at least a certain amount of time). This class cannot be inherited.
Inheritance
Namespace: Umbraco.Cms.Core
Assembly: Umbraco.Core.dll
Syntax
public sealed class TimedScope
Constructors
View SourceTimedScope(long)
Initializes a new instance of the TimedScope class.
Declaration
public TimedScope(long millisecondsDuration)
Parameters
| Type | Name | Description |
|---|---|---|
| long | millisecondsDuration | The number of milliseconds the scope should at least take. |
TimedScope(long, CancellationToken)
Initializes a new instance of the TimedScope class.
Declaration
public TimedScope(long millisecondsDuration, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| long | millisecondsDuration | The number of milliseconds the scope should at least take. |
| CancellationToken | cancellationToken | The cancellation token. |
TimedScope(long, TimeProvider)
Initializes a new instance of the TimedScope class.
Declaration
public TimedScope(long millisecondsDuration, TimeProvider timeProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| long | millisecondsDuration | The number of milliseconds the scope should at least take. |
| TimeProvider | timeProvider | The time provider. |
TimedScope(long, TimeProvider, CancellationToken)
Initializes a new instance of the TimedScope class.
Declaration
public TimedScope(long millisecondsDuration, TimeProvider timeProvider, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| long | millisecondsDuration | The number of milliseconds the scope should at least take. |
| TimeProvider | timeProvider | The time provider. |
| CancellationToken | cancellationToken | The cancellation token. |
TimedScope(TimeSpan)
Initializes a new instance of the TimedScope class.
Declaration
public TimedScope(TimeSpan duration)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | The duration the scope should at least take. |
TimedScope(TimeSpan, CancellationToken)
Initializes a new instance of the TimedScope class.
Declaration
public TimedScope(TimeSpan duration, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | The duration the scope should at least take. |
| CancellationToken | cancellationToken | The cancellation token. |
TimedScope(TimeSpan, TimeProvider)
Initializes a new instance of the TimedScope class.
Declaration
public TimedScope(TimeSpan duration, TimeProvider timeProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | The duration the scope should at least take. |
| TimeProvider | timeProvider | The time provider. |
TimedScope(TimeSpan, TimeProvider, CancellationToken)
Initializes a new instance of the TimedScope class.
Declaration
public TimedScope(TimeSpan duration, TimeProvider timeProvider, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | duration | The duration the scope should at least take. |
| TimeProvider | timeProvider | The time provider. |
| CancellationToken | cancellationToken | The cancellation token. |
Properties
View SourceElapsed
Gets the elapsed time.
Declaration
public TimeSpan Elapsed { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan | The elapsed time. |
Remaining
Gets the remaining time.
Declaration
public TimeSpan Remaining { get; }
Property Value
| Type | Description |
|---|---|
| TimeSpan | The remaining time. |
Methods
View SourceCancel()
Cancels the timed scope.
Declaration
public void Cancel()
CancelAsync()
Cancels the timed scope asynchronously.
Declaration
public Task CancelAsync()
Returns
| Type | Description |
|---|---|
| Task |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Remarks
This will block using System.Threading.Thread.Sleep(System.TimeSpan) until the remaining time has elapsed, if not cancelled.
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
Declaration
public ValueTask DisposeAsync()
Returns
| Type | Description |
|---|---|
| ValueTask | A task that represents the asynchronous dispose operation. |
Remarks
This will delay using System.Threading.Tasks.Task.Delay(System.TimeSpan, System.TimeProvider, System.Threading.CancellationToken) until the remaining time has elapsed, if not cancelled.