瀏覽代碼

Pass cancellation token

Stepan Goremykin 1 年之前
父節點
當前提交
6512f85ccb
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 1 1
      MediaBrowser.Controller/Entities/Folder.cs
  2. 2 2
      RSSDP/SsdpDevicePublisher.cs

+ 1 - 1
MediaBrowser.Controller/Entities/Folder.cs

@@ -598,7 +598,7 @@ namespace MediaBrowser.Controller.Entities
 
             for (var i = 0; i < childrenCount; i++)
             {
-                await actionBlock.SendAsync(i).ConfigureAwait(false);
+                await actionBlock.SendAsync(i, cancellationToken).ConfigureAwait(false);
             }
 
             actionBlock.Complete();

+ 2 - 2
RSSDP/SsdpDevicePublisher.cs

@@ -243,7 +243,7 @@ namespace Rssdp.Infrastructure
             }
 
             // Do not block synchronously as that may tie up a threadpool thread for several seconds.
-            Task.Delay(_Random.Next(16, (maxWaitInterval * 1000))).ContinueWith((parentTask) =>
+            Task.Delay(_Random.Next(16, (maxWaitInterval * 1000)), cancellationToken).ContinueWith((parentTask) =>
             {
                 // Copying devices to local array here to avoid threading issues/enumerator exceptions.
                 IEnumerable<SsdpDevice> devices = null;
@@ -281,7 +281,7 @@ namespace Rssdp.Infrastructure
                         }
                     }
                 }
-            });
+            }, cancellationToken);
         }
 
         private IEnumerable<SsdpDevice> GetAllDevicesAsFlatEnumerable()