Toolbox: Fix race condition by using lock

This commit is contained in:
genteure 2021-11-25 23:34:11 +08:00
parent 32d49c70fc
commit 209fb8c45c

View File

@ -35,9 +35,12 @@ namespace BililiveRecorder.ToolBox.Tool.DanmakuStartTime
{
var el = (XNode.ReadFrom(r) as XElement)!;
var time = (DateTimeOffset)el.Attribute("start_time");
result.Add(new DanmakuStartTimeResponse.DanmakuStartTime { Path = input, StartTime = time });
lock (result)
result.Add(new DanmakuStartTimeResponse.DanmakuStartTime { Path = input, StartTime = time });
Interlocked.Increment(ref finished);
progress?.Invoke(finished / total);
break;
}