瀏覽代碼

Always create TaskCompletionSource<T> with TaskCreationOptions.RunContinuationsAsynchronously

Bond_009 3 年之前
父節點
當前提交
832da133d8

+ 1 - 1
Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs

@@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
         private readonly ILogger _logger;
         private readonly ILogger _logger;
         private readonly IMediaEncoder _mediaEncoder;
         private readonly IMediaEncoder _mediaEncoder;
         private readonly IServerApplicationPaths _appPaths;
         private readonly IServerApplicationPaths _appPaths;
-        private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
+        private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
         private readonly IServerConfigurationManager _serverConfigurationManager;
         private readonly IServerConfigurationManager _serverConfigurationManager;
         private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
         private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
         private bool _hasExited;
         private bool _hasExited;

+ 1 - 1
Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs

@@ -133,7 +133,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
                 }
                 }
             }
             }
 
 
-            var taskCompletionSource = new TaskCompletionSource<bool>();
+            var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
 
 
             _ = StartStreaming(
             _ = StartStreaming(
                 udpClient,
                 udpClient,

+ 1 - 1
Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs

@@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
 
 
             SetTempFilePath("ts");
             SetTempFilePath("ts");
 
 
-            var taskCompletionSource = new TaskCompletionSource<bool>();
+            var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
 
 
             _ = StartStreaming(response, taskCompletionSource, LiveStreamCancellationTokenSource.Token);
             _ = StartStreaming(response, taskCompletionSource, LiveStreamCancellationTokenSource.Token);
 
 

+ 2 - 2
Emby.Server.Implementations/Net/UdpSocket.cs

@@ -159,7 +159,7 @@ namespace Emby.Server.Implementations.Net
         {
         {
             ThrowIfDisposed();
             ThrowIfDisposed();
 
 
-            var taskCompletion = new TaskCompletionSource<SocketReceiveResult>();
+            var taskCompletion = new TaskCompletionSource<SocketReceiveResult>(TaskCreationOptions.RunContinuationsAsynchronously);
             bool isResultSet = false;
             bool isResultSet = false;
 
 
             Action<IAsyncResult> callback = callbackResult =>
             Action<IAsyncResult> callback = callbackResult =>
@@ -195,7 +195,7 @@ namespace Emby.Server.Implementations.Net
         {
         {
             ThrowIfDisposed();
             ThrowIfDisposed();
 
 
-            var taskCompletion = new TaskCompletionSource<int>();
+            var taskCompletion = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
             bool isResultSet = false;
             bool isResultSet = false;
 
 
             Action<IAsyncResult> callback = callbackResult =>
             Action<IAsyncResult> callback = callbackResult =>

+ 1 - 1
MediaBrowser.Common/Extensions/ProcessExtensions.cs

@@ -39,7 +39,7 @@ namespace MediaBrowser.Common.Extensions
             }
             }
 
 
             // Add an event handler for the process exit event
             // Add an event handler for the process exit event
-            var tcs = new TaskCompletionSource<bool>();
+            var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
             process.Exited += (_, _) => tcs.TrySetResult(true);
             process.Exited += (_, _) => tcs.TrySetResult(true);
 
 
             // Return immediately if the process has already exited
             // Return immediately if the process has already exited