共用方式為


DistributedApplication.DisposeAsync Method

Definition

Asynchronously disposes the distributed application by disposing the IHost.

public virtual System.Threading.Tasks.ValueTask DisposeAsync ();
abstract member DisposeAsync : unit -> System.Threading.Tasks.ValueTask
override this.DisposeAsync : unit -> System.Threading.Tasks.ValueTask
Public Overridable Function DisposeAsync () As ValueTask

Returns

A ValueTask representing the asynchronous operation.

Implements

Remarks

Typically developers do not need to worry about calling the Dispose method on the DistributedApplication instance because it is typically used in the entry point of the application and all resources used by the application are destroyed when the application exists.

If you are using the DistributedApplication and IDistributedApplicationBuilder inside unit test code then you should correctly dispose of the DistributedApplication instance. This is because the IDistributedApplicationBuilder instance initializes configuration providers which make use of file watchers which are a finite resource.

Without disposing of the DistributedApplication correctly projects with a large number of functional/integration tests may see a "The configured user limit (128) on the number of inotify instances has been reached, or the per-process limit on the number of open file descriptors has been reached." error.

Refer to the .NET Aspire testing page for more information on how to use .NET Aspire APIs for functional an integrating testing.

Applies to