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
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:
Alternatively, as suggested by @DannyVarod, you can use a
Stopwatchto achieve the same result (but with more accurate timing):