private async Task ReturnIndex() { using (var l = await _mutex.Lock()) { if (_pool != null) { _pool.ReturnIndex(Value); _pool = null; } } }
// private readonly AsyncMutex _mutex = new AsyncMutex(); public PoolIndex(IndexPool pool, int index) { _pool = pool ?? throw new ArgumentNullException(nameof(pool)); Value = index; }