Refactor naming for background tasks.

This commit is contained in:
Christian
2020-11-25 21:07:50 +01:00
parent 7738c5faa1
commit ec015e7620
6 changed files with 10 additions and 8 deletions
@@ -160,7 +160,7 @@ namespace MQTTnet.Server
await SendAsync(_channelAdapter.PacketFormatterAdapter.DataConverter.CreateConnAckPacket(_connectionValidatorContext), cancellationToken).ConfigureAwait(false);
Task.Run(() => SendPendingPacketsAsync(cancellationToken), cancellationToken).Forget(_logger);
Task.Run(() => SendPendingPacketsAsync(cancellationToken), cancellationToken).RunInBackground(_logger);
Session.IsCleanSession = false;
@@ -50,7 +50,7 @@ namespace MQTTnet.Server
public void Start(CancellationToken cancellationToken)
{
Task.Run(() => TryProcessQueuedApplicationMessagesAsync(cancellationToken), cancellationToken).Forget(_logger);
Task.Run(() => TryProcessQueuedApplicationMessagesAsync(cancellationToken), cancellationToken).RunInBackground(_logger);
}
public async Task HandleClientConnectionAsync(IMqttChannelAdapter channelAdapter, CancellationToken cancellationToken)
@@ -29,7 +29,7 @@ namespace MQTTnet.Server
// support async/await. Async etc. is avoided here because the thread will usually check
// the connections every few milliseconds and thus the context changes (due to async) are
// only consuming resources. Also there is just 1 thread for the entire server which is fine at all!
Task.Factory.StartNew(_ => DoWork(cancellationToken), cancellationToken, TaskCreationOptions.LongRunning).Forget(_logger);
Task.Factory.StartNew(_ => DoWork(cancellationToken), cancellationToken, TaskCreationOptions.LongRunning).RunInBackground(_logger);
}
void DoWork(CancellationToken cancellationToken)