diff --git a/cs/src/core/Device/FixedPool.cs b/cs/src/core/Device/FixedPool.cs index 522cc2205..0242dda97 100644 --- a/cs/src/core/Device/FixedPool.cs +++ b/cs/src/core/Device/FixedPool.cs @@ -26,7 +26,7 @@ public FixedPool(int size, Func creator) { while (true) { - for (int i=0; i creator) { if (Interlocked.CompareExchange(ref owners[i], 2, val) == val) { - items[i] = creator(); + try + { + items[i] = creator(); + } + catch + { + Interlocked.Exchange(ref owners[i], val); + throw; + } + return (items[i], i); } }