Use Task.Run instead of Task.Factory.StartNew (#611)
Addresses #571 Using `TaskCreationOptions.LongRunning` creates a dedicated thread, but it's released on the first await. Using Task.Run uses the thread pool instead
This commit is contained in:
parent
22097c6c35
commit
e21dc21b40
|
|
@ -75,7 +75,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices
|
|||
|
||||
internal abstract Task WriteMessagesAsync(IEnumerable<LogMessage> messages, CancellationToken token);
|
||||
|
||||
private async Task ProcessLogQueue(object state)
|
||||
private async Task ProcessLogQueue()
|
||||
{
|
||||
while (!_cancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
|
|
@ -143,10 +143,7 @@ namespace Microsoft.Extensions.Logging.AzureAppServices
|
|||
new BlockingCollection<LogMessage>(new ConcurrentQueue<LogMessage>(), _queueSize.Value);
|
||||
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
_outputTask = Task.Factory.StartNew<Task>(
|
||||
ProcessLogQueue,
|
||||
null,
|
||||
TaskCreationOptions.LongRunning);
|
||||
_outputTask = Task.Run(ProcessLogQueue);
|
||||
}
|
||||
|
||||
private void Stop()
|
||||
|
|
|
|||
Loading…
Reference in New Issue