Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay operator doesn't work in WPF #296

Open
Boredbone opened this issue Jan 24, 2025 · 0 comments
Open

Delay operator doesn't work in WPF #296

Boredbone opened this issue Jan 24, 2025 · 0 comments

Comments

@Boredbone
Copy link

Delay operator doesn't work under WpfDispatcherTimerProvider.

I think, self.timer.InvokeOnce(self.dueTime - elapsed); is called in Delay<T>._Delay.DrainMessages, but after that, timer.Stop(); is called in WpfDispatcherTimerProviderTimer.Timer_Tick, so it may be unintended behavior.

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        WpfProviderInitializer.SetDefaultObservableSystem(ex => { });
    }
    protected override void OnActivated(EventArgs e)
    {
        base.OnActivated(e);

        Observable.Return(Unit.Default)
            .Delay(TimeSpan.FromSeconds(1), TimeProvider.System)
            .Subscribe(_ => Debug.WriteLine("This works fine"));

        Observable.Return(Unit.Default)
            .Delay(TimeSpan.FromSeconds(1))
            .Subscribe(_ => Debug.WriteLine("but here is not reached"));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant