dotnet / dotnet/dotnet-api-docs

`PeriodicTimer.WaitForNextTickAsync`: Describe meaning of returned `bool` values

Open
#10,274 1 comment 1 reaction 0 assignees View on GitHub
area-System.Threading.Tasks Pri3 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 return value for `WaitForNextTickAsync` is a `ValueTask`, but the documentation doesn't say what `true` or `false` mean as the value of that task, only when the task will be completed.

I would expect to see something like

> The task will have value `true` when running normally, or `false` when the timer has been stopped.

And maybe an example showing a

```cs
while (await timer.WaitForNextTick()) {
// ... do work ...
}
```

loop as the canonical way to consume the timer. (Well, if that's right -- I don't know.)

But having a "see also" (cc https://github.com/dotnet/dotnet-api-docs/issues/7451#issuecomment-996424793) to an article about how to use `PeriodicTimer` instead of an example would also be fine. (There's no example on the class-level documentation page either.)

### Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.threading.periodictimer.waitfornexttickasync?view=net-8.0#system-threading-periodictimer-waitfornexttickasync(system-threading-cancellationtoken)

### Content source URL

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

### Document Version Independent Id

0ef31de4-0c6b-4ae5-b172-c2e89beee4cc

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