Skip to content

Extend SemaphoreSlim WaitAsync millisecond bound to Timer.MaxSupportedTimeout to match Timer and other APIs #116877

Closed

Description

@prvyk

Currently, SemaphoreSlim WaitAsync limits itself to int.MaxValue milliseconds. Yet the underlying APIs support (almost) the uint full range, as do CancellationTokenSource and Task.Delay (see #43708).

SemaphoreSlim WaitAsync's range should be extended to match the other APIs to be more consistent and for the same reasons Task.Delay was extended to support the full range, e.g. supporting timeouts for a full month.

Real world use case:

microsoft/garnet implements RESP blocking commands using SemaphoreSlim.WaitAsync. Most implementations accept even large timeouts than int.MaxValue milliseconds, UINT32.MaxValue - 1 is more compatible with existing practice.

Example:

                SemaphoreSlim slim = new(0, 1);
                Console.WriteLine("start");
                await slim.WaitAsync(TimeSpan.FromDays(30));
                Console.WriteLine("do something");

Activity

  1. added
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Jun 20, 2025
  2. added and removed
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Jun 20, 2025
  3. dotnet-policy-service commented on Jun 20, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @mangod9
    See info in area-owners.md if you want to be subscribed.

  4. removed
    untriagedNew issue has not been triaged by the area owner
    on Jul 1, 2025
  5. added this to the 11.0.0 milestone on Jul 1, 2025
  6. locked and limited conversation to collaborators on Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions