Skip to content

Add warning about disabled timer? #12332

@ygoe

Description

@ygoe

Type of issue

Missing information

Description

The page explains how I can disable the timer by setting dueTime to -1. I guess that's my interpretation. But there's also the period parameter that runs the timer at the specified interval. In no word is mentioned that the period will be ignored if no dueTime was set.

I only need an interval timer, not a delayed-once timer. So I set dueTime to Infinite/-1 and period to the desired interval. From my debugging output, I assume that my timer has ended up disabled. Not good.

I suggest adding an explicit warning (to all cunstructor overloads) that period is ignored when dueTime is Infinite/-1. That's really not intuitive. A suggested workaround would also be welcome. Set the period also for dueTime?

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.threading.timer.-ctor?view=net-10.0#system-threading-timer-ctor(system-threading-timercallback-system-object-system-timespan-system-timespan)

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Threading/Timer.xml

Document Version Independent Id

832e8e3c-e498-bbea-44dc-81c60d696705

Platform Id

c1d51610-7405-6c58-a3a3-dc864e3e0caf

Article author

@dotnet-bot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions