Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7159565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:15:08+00:00 2026-05-28T13:15:08+00:00

When the user does something (touch on a StackPanel, in this case), I need

  • 0

When the user does something (touch on a StackPanel, in this case), I need to begin a timer of some sort (probably DispatcherTimer as I’m working in WPF) and if another touch happens again within a certain amount of time then I’ll call a method. As you can probably guess – this is to implement a double-tap functionality.

I’m assuming the best way to achieve this is through using threads (i.e. a child thread to increment a timespan which can be checked by the Main thread any time the StackPanel is touched again?)

Thanks,

Dan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:15:08+00:00Added an answer on May 28, 2026 at 1:15 pm

    You do not need to start another thread to do this.

    Just take a timestamp of when the first tap happened and use this. You can then calculate the timespan by subtracting this time from the current time:

    private DateTime _lastTap;
    public void TapHandler()
    {
      DateTime now = DateTime.UtcNow;
      TimeSpan span = now - lastTap;
      _lastTap = now;
      if (span < TimeSpan.FromSeconds(1)) {...}
    }
    

    Alternatively, as suggested by @DannyVarod, you can use a Stopwatch to achieve the same result (but with more accurate timing):

    private Stopwatch _stopwatch = new Stopwatch();
    public void TapHandler()
    {
      TimeSpan elapsed = _stopwatch.Elapsed;
      _stopwatch.Restart();
      if (elapsed < TimeSpan.FromSeconds(1)) {...}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to make a bash script that takes user input and does some
I'd like to code something that is aware of specific wordpress user roles. Does
I have swipeleft/swiperight working well in my app but when the user does the
I need to know which views does a user have which privileges on. I'm
Whenever a user does something a a series of scripts are executing, after everything
hi we try to implement a process like when a user does something, his
A user wants me to create an app that does something everything he presses
Does something like this affect performance badly? var myQuery = from c in Customers
I had a working Rails site which I did not touch for some time.
When a user does something like create a blog post or upload a photo,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.