Skip to content

Commit

Permalink
feat: add AppHostStartedMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
WeihanLi committed Aug 19, 2023
1 parent bc807a9 commit 3447eac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/WeihanLi.Common/Helpers/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public sealed class AppHost : IAppHost
{
private const string
AppHostStartingMessage = "AppHost starting",
AppHostStartedMessage = "AppHost started. Press Ctrl+C to shut down",
AppHostStoppedMessage = "AppHost stopped"
;

Expand All @@ -106,6 +107,8 @@ public async Task RunAsync(CancellationToken cancellationToken = default)
var exitToken = CancellationTokenSource.CreateLinkedTokenSource(InvokeHelper.GetExitToken(), cancellationToken);
var waitForStopTask = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
exitToken.Token.Register(() => waitForStopTask.TrySetResult());
Debug.WriteLine(AppHostStartedMessage);
_logger.LogInformation(AppHostStartedMessage);
await waitForStopTask.Task.ConfigureAwait(false);
Debug.WriteLine(AppHostStoppedMessage);
_logger.LogInformation(AppHostStoppedMessage);
Expand Down

0 comments on commit 3447eac

Please sign in to comment.