Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Bedrock.Framework/Server/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ public class Server
private readonly ILogger<Server> _logger;
private readonly List<RunningListener> _listeners = new List<RunningListener>();
private readonly TaskCompletionSource<object> _shutdownTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
private readonly TimerAwaitable _timerAwaitable;
private TimerAwaitable _timerAwaitable;
private Task _timerTask = Task.CompletedTask;

internal Server(ServerBuilder builder)
{
_logger = builder.ApplicationServices.GetLoggerFactory().CreateLogger<Server>();
_builder = builder;
_timerAwaitable = new TimerAwaitable(_builder.HeartBeatInterval, _builder.HeartBeatInterval);
}

public IEnumerable<EndPoint> EndPoints
Expand All @@ -38,6 +37,8 @@ public IEnumerable<EndPoint> EndPoints

public async Task StartAsync(CancellationToken cancellationToken = default)
{
_timerAwaitable = new TimerAwaitable(_builder.HeartBeatInterval, _builder.HeartBeatInterval);

try
{
foreach (var binding in _builder.Bindings)
Expand Down Expand Up @@ -111,6 +112,8 @@ public async Task StopAsync(CancellationToken cancellationToken = default)
_timerAwaitable.Stop();

await _timerTask.ConfigureAwait(false);

_timerAwaitable = null;
}
}

Expand Down