Skip to content

Commit 03b2ac6

Browse files
authored
Avoid new delegate allocation on each DispatcherTimer tick (#4717)
1 parent 111341f commit 03b2ac6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Threading/DispatcherTimer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ private void Restart()
267267
// BeginInvoke a new operation.
268268
_operation = _dispatcher.BeginInvoke(
269269
DispatcherPriority.Inactive,
270-
new DispatcherOperationCallback(FireTick),
271-
null);
270+
(DispatcherOperationCallback)(state => ((DispatcherTimer)state).FireTick()),
271+
this);
272272

273273

274274
_dueTimeInTicks = Environment.TickCount + (int) _interval.TotalMilliseconds;
@@ -297,7 +297,7 @@ internal void Promote() // called from Dispatcher
297297
}
298298
}
299299

300-
private object FireTick(object unused)
300+
private object FireTick()
301301
{
302302
// The operation has been invoked, so forget about it.
303303
_operation = null;

0 commit comments

Comments
 (0)