ResourceNotificationService.WaitForResourceHealthyAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
WaitForResourceHealthyAsync(String, CancellationToken) |
Waits for a resource to become healthy. |
WaitForResourceHealthyAsync(String, WaitBehavior, CancellationToken) |
Waits for a resource to become healthy. |
WaitForResourceHealthyAsync(String, CancellationToken)
Waits for a resource to become healthy.
public System.Threading.Tasks.Task<Aspire.Hosting.ApplicationModel.ResourceEvent> WaitForResourceHealthyAsync(string resourceName, System.Threading.CancellationToken cancellationToken = default);
member this.WaitForResourceHealthyAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Aspire.Hosting.ApplicationModel.ResourceEvent>
Public Function WaitForResourceHealthyAsync (resourceName As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceEvent)
Parameters
- resourceName
- String
The name of the resource.
- cancellationToken
- CancellationToken
The cancellation token.
Returns
A task.
Remarks
This method returns a task that will complete with the resource is healthy. A resource without HealthCheckAnnotation annotations will be considered healthy once it reaches a Running state.
If the resource enters an unavailable state such as FailedToStart then this method will continue to wait to enable scenarios where a resource could be restarted and recover. To control this behavior use WaitForResourceHealthyAsync(String, WaitBehavior, CancellationToken) or configure the default behavior with DefaultWaitBehavior.
Applies to
WaitForResourceHealthyAsync(String, WaitBehavior, CancellationToken)
Waits for a resource to become healthy.
public System.Threading.Tasks.Task<Aspire.Hosting.ApplicationModel.ResourceEvent> WaitForResourceHealthyAsync(string resourceName, Aspire.Hosting.ApplicationModel.WaitBehavior waitBehavior, System.Threading.CancellationToken cancellationToken = default);
member this.WaitForResourceHealthyAsync : string * Aspire.Hosting.ApplicationModel.WaitBehavior * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Aspire.Hosting.ApplicationModel.ResourceEvent>
Public Function WaitForResourceHealthyAsync (resourceName As String, waitBehavior As WaitBehavior, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceEvent)
Parameters
- resourceName
- String
The name of the resource.
- waitBehavior
- WaitBehavior
The wait behavior.
- cancellationToken
- CancellationToken
The cancellation token.
Returns
A task.
Remarks
This method returns a task that will complete with the resource is healthy. A resource without HealthCheckAnnotation annotations will be considered healthy once it reaches a Running state. The WaitBehavior controls how the wait operation behaves when the resource enters an unavailable state such as FailedToStart.
When WaitOnResourceUnavailable is specified the wait operation will continue to wait until the resource reaches a Running state.
When StopOnResourceUnavailable is specified the wait operation will throw a DistributedApplicationException if the resource enters an unavailable state.