ResourceNotificationService.WaitForResourceAsync Method

Definition

Overloads

WaitForResourceAsync(String, IEnumerable<String>, CancellationToken)

Waits for a resource to reach one of the specified states. See KnownResourceStates for common states.

WaitForResourceAsync(String, Func<ResourceEvent,Boolean>, CancellationToken)

Waits until a resource satisfies the specified predicate.

WaitForResourceAsync(String, String, CancellationToken)

Waits for a resource to reach the specified state. See KnownResourceStates for common states.

WaitForResourceAsync(String, IEnumerable<String>, CancellationToken)

Source:
ResourceNotificationService.cs
Source:
ResourceNotificationService.cs
Source:
ResourceNotificationService.cs

Waits for a resource to reach one of the specified states. See KnownResourceStates for common states.

C#
public System.Threading.Tasks.Task<string> WaitForResourceAsync(string resourceName, System.Collections.Generic.IEnumerable<string> targetStates, System.Threading.CancellationToken cancellationToken = default);

Parameters

resourceName
String

The name of the resource.

targetStates
IEnumerable<String>

The set of states to wait for the resource to transition to one of. See KnownResourceStates for common states.

cancellationToken
CancellationToken

A cancellation token that cancels the wait operation when signaled.

Returns

A Task<TResult> representing the wait operation and which of the target states the resource reached.

Remarks

This method returns a task that will complete when the resource reaches one of the specified target states. If the resource is already in the target state, the method will return immediately.
If the resource doesn't reach one of the target states before cancellationToken is signaled, this method will throw OperationCanceledException.

Applies to

.NET Aspire 9.1.0 and other versions
Product Versions
.NET Aspire 8.0.0, 9.0.0, 9.1.0

WaitForResourceAsync(String, Func<ResourceEvent,Boolean>, CancellationToken)

Source:
ResourceNotificationService.cs
Source:
ResourceNotificationService.cs

Waits until a resource satisfies the specified predicate.

C#
public System.Threading.Tasks.Task<Aspire.Hosting.ApplicationModel.ResourceEvent> WaitForResourceAsync(string resourceName, Func<Aspire.Hosting.ApplicationModel.ResourceEvent,bool> predicate, System.Threading.CancellationToken cancellationToken = default);

Parameters

resourceName
String

The name of the resource.

predicate
Func<ResourceEvent,Boolean>

A predicate which is evaluated for each ResourceEvent for the selected resource.

cancellationToken
CancellationToken

A cancellation token that cancels the wait operation when signaled.

Returns

A Task<TResult> representing the wait operation and which of the target states the resource reached.

Remarks

This method returns a task that will complete when the specified predicate returns true.
If the predicate isn't satisfied before cancellationToken is signaled, this method will throw OperationCanceledException.

Applies to

.NET Aspire 9.1.0 and .NET Aspire 9.0.0
Product Versions
.NET Aspire 9.0.0, 9.1.0

WaitForResourceAsync(String, String, CancellationToken)

Source:
ResourceNotificationService.cs
Source:
ResourceNotificationService.cs
Source:
ResourceNotificationService.cs

Waits for a resource to reach the specified state. See KnownResourceStates for common states.

C#
public System.Threading.Tasks.Task WaitForResourceAsync(string resourceName, string? targetState = default, System.Threading.CancellationToken cancellationToken = default);

Parameters

resourceName
String

The name of the resource.

targetState
String

The state to wait for the resource to transition to. See KnownResourceStates for common states.

cancellationToken
CancellationToken

A CancellationToken.

Returns

A Task representing the wait operation.

Remarks

This method returns a task that will complete when the resource reaches the specified target state. If the resource is already in the target state, the method will return immediately.
If the resource doesn't reach one of the target states before cancellationToken is signaled, this method will throw OperationCanceledException.

Applies to

.NET Aspire 9.1.0 and other versions
Product Versions
.NET Aspire 8.0.0, 9.0.0, 9.1.0