ForEachAsync

/// <summary>
/// 使用异步遍历处理数据
/// </summary>
/// <typeparam name="T">需要遍历的基类</typeparam>
/// <param name="list">集合</param>
/// <param name="func">Lambda表达式</param>
/// <returns></returns>
public static async Task ForEachAsync<T>(this List<T> list, Func<T, Task> func)
{
    foreach (T value in list)
    {
        await func(value);
    }
}

posted on 2022-05-20 10:57  隨風.NET  阅读(59)  评论(0编辑  收藏  举报

导航