-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
DoneThis issue has been fixedThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-blazor-desktopThis issue is related to Blazor DesktopThis issue is related to Blazor Desktop
Milestone
Description
Component timers do not work in Blazor Desktop on WPF .net6 Preview 3.
Repro is to clone the current demo-app (https://github.com/danroth27/BlazorDesktopWPF) and add a timer in the counter.razor.
@namespace BlazorDesktopWPF
@using Microsoft.AspNetCore.Components.Web
@using System.Timers
<h1>Counter</h1>
<p>The current count is: @currentCount</p>
<button @onclick="IncrementCount">Count</button>
@code {
int currentCount = 1;
void IncrementCount()
{
currentCount++;
}
Timer _timer;
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
_timer = new Timer();
_timer.Elapsed += callback;
_timer.Interval = 1000;
_timer.Start();
}
}
public async void callback(object sender, ElapsedEventArgs e)
{
currentCount++;
await InvokeAsync(StateHasChanged);
}
}
Exception:
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
InvalidOperationException: Received unexpected acknowledgement for render batch 4 (next batch should be 3)
I tried System.Threading timer and SystemTimers timer.
Metadata
Metadata
Assignees
Labels
DoneThis issue has been fixedThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-blazor-desktopThis issue is related to Blazor DesktopThis issue is related to Blazor Desktop