Skip to content

Commit

Permalink
Ready for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
machonky committed Jun 12, 2024
1 parent 96c562b commit 9e051f6
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,11 @@ public abstract class BackgroundWorkerBase : IBackgroundWorker

protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance);

protected CancellationTokenSource StoppingTokenSource { get; private set; }
protected CancellationTokenSource StoppingTokenSource { get; set; }

protected CancellationToken StoppingToken { get; private set; }
protected CancellationToken StoppingToken { get; set; }

public BackgroundWorkerBase()
{
ResetStoppingCancellationTokenSource();
}

private void ResetStoppingCancellationTokenSource()
{
StoppingTokenSource = new CancellationTokenSource();
StoppingToken = StoppingTokenSource.Token;
Expand All @@ -47,10 +42,7 @@ public virtual Task StopAsync(CancellationToken cancellationToken = default)
{
Logger.LogDebug("Stopped background worker: " + ToString());
StoppingTokenSource.Cancel();
StoppingTokenSource.Dispose();

ResetStoppingCancellationTokenSource();

StoppingTokenSource.Dispose();
return Task.CompletedTask;
}

Expand Down

0 comments on commit 9e051f6

Please sign in to comment.