dotnet / dotnet/dotnet-api-docs

What happens when SemaphoreSlim.Wait(Int32) times out

Open
#1,554 0 comments 0 reactions 0 assignees View on GitHub
area-System.Threading dotnet-api/prod Pri2 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

Multiple times the documentation states:

> If a thread or task is blocked when calling Wait(Int32) and the timeout interval specified by millisecondsTimeout expires:
>
> - The thread or task doesn't enter the semaphore.
> - The CurrentCount property isn't decremented.

It tells us what won't happen to the thread, but it doesn't tell us what _will_ happen to the thread. Does it just block forever? Does it terminate? Does it throw an exception?

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 87434137-295a-3efb-aa58-2a8186142f15
* Version Independent ID: 007f95cb-7691-1634-521a-1369a69f3a70
* Content: [SemaphoreSlim.Wait Method (System.Threading)](https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim.wait?view=netframework-4.7.2)
* Content Source: [xml/System.Threading/SemaphoreSlim.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Threading/SemaphoreSlim.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.