Skip to content

Incorrect example #10843

Open
Open
@dmitrypyzh

Description

@dmitrypyzh

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

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