dotnet / dotnet/dotnet-api-docs
DispatcherTimer ctor does not indicate that Start will be called automatically
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
The [`DispatcherTimer(TimeSpan, DispatcherPriority, EventHandler, Dispatcher)` Constructor](https://docs.microsoft.com/en-us/dotnet/api/system.windows.threading.dispatchertimer.-ctor?view=netframework-4.7.1#System_Windows_Threading_DispatcherTimer__ctor_System_TimeSpan_System_Windows_Threading_DispatcherPriority_System_EventHandler_System_Windows_Threading_Dispatcher_) automatically starts/enables the instance, and neither IntelliSense nor the [documentation](https://github.com/dotnet/docs/blob/master/xml/System.Windows.Threading/DispatcherTimer.xml#L137) indicate that this is the case.
We were wondering why the code behaved differently, thinking this was only a short-hand form of specifying all parameters at once (vs. attaching the EventHandler using `+=` afterwards); but looking at the source revealed that it actually calls [`Start`](https://docs.microsoft.com/en-us/dotnet/api/system.windows.threading.dispatchertimer.start?view=netframework-4.7.1).
I have no idea how to express this concisely, otherwise I'd have opened a pull request right away.
Other than adding this note to the summary (which I believe should be done to make it clear in IntelliSense inside VS right away), it might be a good idea to provide an example on when this would be useful (or could be used over the other alternatives), or at least a remark highlighting this distinction.
Contributor guide
Assessment
This issue has not been assessed yet.