Files
Umbraco-CMS/src/Umbraco.Core/Composing/IAsyncComponent.cs
Ronald Barendse cf6137db18 Add IAsyncComponent to allow async initialize/terminate (#16536)
* Add IAsyncComponent

* Rewrite to use IAsyncComposer

* Add AsyncComponentBase and RuntimeAsyncComponentBase

* Remove manual disposing of components on restart
2024-09-23 09:45:46 +02:00

36 lines
1.4 KiB
C#

namespace Umbraco.Cms.Core.Composing;
/// <summary>
/// Represents a component.
/// </summary>
/// <remarks>
/// <para>
/// Components are created by DI and therefore must have a public constructor.
/// </para>
/// <para>
/// All components are terminated in reverse order when Umbraco terminates, and disposable components are disposed.
/// </para>
/// </remarks>
public interface IAsyncComponent
{
/// <summary>
/// Initializes the component.
/// </summary>
/// <param name="isRestarting">If set to <c>true</c> indicates Umbraco is restarting.</param>
/// <param name="cancellationToken">The cancellation token. Cancellation indicates that the start process has been aborted.</param>
/// <returns>
/// A <see cref="Task" /> representing the asynchronous operation.
/// </returns>
Task InitializeAsync(bool isRestarting, CancellationToken cancellationToken);
/// <summary>
/// Terminates the component.
/// </summary>
/// <param name="isRestarting">If set to <c>true</c> indicates Umbraco is restarting.</param>
/// <param name="cancellationToken">The cancellation token. Cancellation indicates that the shutdown process should no longer be graceful.</param>
/// <returns>
/// A <see cref="Task" /> representing the asynchronous operation.
/// </returns>
Task TerminateAsync(bool isRestarting, CancellationToken cancellationToken);
}