From 0470da1e895c6efc1643d747c8a2eddc4d43a2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Lema=C5=84czyk?= Date: Tue, 9 Sep 2025 21:28:22 +0200 Subject: [PATCH] Serialize GPU context disposal --- PerfectNumbers.Core/Gpu/GpuContextPool.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 {