diff --git a/PerfectNumbers.Core/Gpu/GpuContextPool.cs b/PerfectNumbers.Core/Gpu/GpuContextPool.cs index be545a3..d9b9414 100644 --- a/PerfectNumbers.Core/Gpu/GpuContextPool.cs +++ b/PerfectNumbers.Core/Gpu/GpuContextPool.cs @@ -114,11 +114,14 @@ public static class GpuContextPool } } - else - { - ctx.Dispose(); - } - } + else + { + lock (CreationLock) + { + ctx.Dispose(); + } + } + } public struct GpuContextLease : IDisposable {