Skip to content

DispatcherQueueTimerExtensions.Debounce does not work with leading edge action #143

Closed
@huynhsontung

Description

@huynhsontung

Describe the bug

Debounce(immediate: true) does not work with a default timer. When a timer is created, IsRepeating is set to true by default. This breaks the logic of Debounce when immediate: true. Setting IsRepeating to false on the timer fixes this issue.

Steps to reproduce

  1. Create a DispatcherQueueTimer using DispatcherQueue.GetForCurrentThread().CreateTimer()
  2. Use Debounce() on that timer with immediate: true
  3. The action is only triggered once and never again.

Expected behavior

Subsequent actions should trigger once the timer expires just like without the immediate flag.

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Other (specify)

Visual Studio Version

2022

Help us help you

Yes, I'd like to be assigned to work on this item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions