fix: lock timing handle list while using

This commit is contained in:
goaaats 2022-06-26 16:18:58 +02:00
parent 36780f43a8
commit d079bc1fbf
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -19,6 +19,7 @@ public sealed class TimingHandle : TimingEvent, IDisposable, IComparable<TimingH
{
this.Stack = Timings.TaskTimingHandles;
lock (this.Stack)
this.Parent = this.Stack.LastOrDefault();
if (this.Parent != null)
@ -36,6 +37,7 @@ public sealed class TimingHandle : TimingEvent, IDisposable, IComparable<TimingH
this.EndTime = this.StartTime;
this.IsMainThread = ThreadSafety.IsMainThread;
lock (this.Stack)
this.Stack.Add(this);
}
@ -78,7 +80,10 @@ public sealed class TimingHandle : TimingEvent, IDisposable, IComparable<TimingH
public void Dispose()
{
this.EndTime = Timings.Stopwatch.Elapsed.TotalMilliseconds;
lock (this.Stack)
this.Stack.Remove(this);
if (this.Duration > 1 || this.ChildCount > 0)
{
lock (Timings.AllTimings)