Skip to content

Commit

Permalink
Messge host restart - suppress flow fix (#268)
Browse files Browse the repository at this point in the history
* Messge host restart - suppress flow fix

* Add comment for uprade
  • Loading branch information
fraliv13 authored Oct 13, 2023
1 parent b280503 commit 950d015
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Messaging/NBB.Messaging.Host/Internal/MessagingHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ public void ScheduleRestart(TimeSpan delay = default)
return;

_logger.LogInformation($"Messaging host is scheduled for restart in {delay.TotalSeconds} seconds");

// TODO: when upgrading to .NET 8 remove the "suppressed" check since it doesn't throw any more
// https://github.com/dotnet/runtime/pull/82912
using IDisposable _ = ExecutionContext.IsFlowSuppressed() ? null : ExecutionContext.SuppressFlow();

Task.Run(async () =>
{
try
{
await Task.Delay(delay);

if (!ExecutionContext.IsFlowSuppressed())
ExecutionContext.SuppressFlow();

await TryStopAsync();
await StartAsync();
}
Expand Down

0 comments on commit 950d015

Please sign in to comment.