dotnet / dotnet/dotnet-api-docs
Incorrect example
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
### Type of issue
Code doesn't work
### Description
++invokeCount in example must called under lock or interlocked because:
"The callback method executed by the timer should be reentrant, because it is called on ThreadPool threads. The callback can be executed simultaneously on two thread pool threads if the timer interval is less than the time required to execute the callback, or if all thread pool threads are in use and the callback is queued multiple times."
### Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.threading.timer?view=net-9.0
### Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Threading/Timer.xml
### Document Version Independent Id
987f743c-c849-522e-b662-e520c1efaed1
### Article author
@dotnet-bot
Contributor guide
Assessment
This issue has not been assessed yet.