File tree Expand file tree Collapse file tree
Common.BasicHelper/Utils/Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using System . Threading ;
34using System . Threading . Tasks ;
45
56namespace Common . BasicHelper . Utils . Extensions ;
@@ -57,8 +58,12 @@ public static Queue<T> Pop<T>(this Queue<T> queue)
5758 /// <param name="reappend">是否将出队元素重新入队</param>
5859 /// <param name="locker">操作锁</param>
5960 /// <returns>队列本身</returns>
60- public static Queue < T > ForEach < T > ( this Queue < T > queue , Action < T > action ,
61- bool reappend = false , object ? locker = null )
61+ public static Queue < T > ForEach < T > (
62+ this Queue < T > queue ,
63+ Action < T > action ,
64+ bool reappend = false ,
65+ object ? locker = null
66+ )
6267 {
6368 Queue < T > func ( )
6469 {
@@ -92,8 +97,12 @@ Queue<T> func()
9297 /// <param name="reappend">是否将出队元素重新入队</param>
9398 /// <param name="locker">操作锁</param>
9499 /// <returns>返回队列本身的任务</returns>
95- public static async Task < Queue < T > > ForEachAsync < T > ( this Queue < T > queue , Action < T > action ,
96- bool reappend = false )
100+ public static async Task < Queue < T > > ForEachAsync < T > (
101+ this Queue < T > queue ,
102+ Action < T > action ,
103+ bool reappend = false ,
104+ CancellationToken token = default
105+ )
97106 {
98107 Queue < T > func ( )
99108 {
@@ -108,6 +117,6 @@ Queue<T> func()
108117 return queue ;
109118 }
110119
111- return await Task . Run ( func ) ;
120+ return await Task . Run ( func , token ) ;
112121 }
113122}
You can’t perform that action at this time.
0 commit comments