dotnetcore / dotnetcore/EasyCaching

System.ObjectDisposedException: Cannot access a disposed object 'System.Threading.SemaphoreSlim'

Open
#525 1 comment 0 reactions 1 assignee Claimed by @Memoyu View on GitHub
area-lock
Dominant language
C#
Stars
2.1k
Forks
336
PR merge metrics
No merged PRs in 30d

Description

## Description

I cannot always reproduce this, but this happens in my concurrent test code and my business code is using MemoryLockFactory from EasyCaching.Core.

```
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Threading.SemaphoreSlim'.
at System.Threading.SemaphoreSlim.WaitAsync(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at EasyCaching.Core.DistributedLock.MemoryLock.LockAsync(Int32 millisecondsTimeout, CancellationToken cancellationToken)
```

### Related code

```csharp
try {
if (await distributedLock.LockAsync(3000)) {
...
}
else {
throw new Exception("xxx");
}
}
finally {
await distributedLock.ReleaseAsync();
}
```

## Specifications

- Provider : InMemory (version 1.9.2)
- Interceptor : AspectCore (version 8.0.0)
- Serializer : not use
- System : Ubuntu20.04

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.