mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix race condition with Do and async
This commit is contained in:
parent
b2a112bd37
commit
1099d68ef7
@ -301,6 +301,17 @@ namespace Wabbajack.Common
|
|||||||
foreach (var i in coll) f(i);
|
foreach (var i in coll) f(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executes the action for every item in coll
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="coll"></param>
|
||||||
|
/// <param name="f"></param>
|
||||||
|
public static async Task DoAsync<T>(this IEnumerable<T> coll, Func<T, Task> f)
|
||||||
|
{
|
||||||
|
foreach (var i in coll) await f(i);
|
||||||
|
}
|
||||||
|
|
||||||
public static void DoIndexed<T>(this IEnumerable<T> coll, Action<int, T> f)
|
public static void DoIndexed<T>(this IEnumerable<T> coll, Action<int, T> f)
|
||||||
{
|
{
|
||||||
var idx = 0;
|
var idx = 0;
|
||||||
|
@ -148,7 +148,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
bw.Write(FileVersion);
|
bw.Write(FileVersion);
|
||||||
bw.Write((ulong) Index.AllFiles.Count);
|
bw.Write((ulong) Index.AllFiles.Count);
|
||||||
|
|
||||||
(await Index.AllFiles
|
await (await Index.AllFiles
|
||||||
.PMap(Queue, f =>
|
.PMap(Queue, f =>
|
||||||
{
|
{
|
||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
@ -156,7 +156,7 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
f.Write(ibw);
|
f.Write(ibw);
|
||||||
return ms;
|
return ms;
|
||||||
}))
|
}))
|
||||||
.Do(async ms =>
|
.DoAsync(async ms =>
|
||||||
{
|
{
|
||||||
var size = ms.Position;
|
var size = ms.Position;
|
||||||
ms.Position = 0;
|
ms.Position = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user