dotnet / dotnet/dotnet-api-docs

Add warning about disabled timer?

Open
#12,332 0 comments 0 reactions 0 assignees View on GitHub
area-System.DateTime untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### 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

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.