Last active
August 29, 2015 14:07
-
-
Save SafeerH/55a2dc87c7b8f6624410 to your computer and use it in GitHub Desktop.
Delayed Trigger (trigger event after 1 second)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Form1 : Form | |
{ | |
private DateTime _lastScrollEvent = new DateTime(0); | |
private async void DetectShapeAsync() | |
{ | |
labelUTVal.Text = (trackBarUniquenessThreshold.Value / 100d).ToString(); | |
labelHTVal.Text = trackBarHessianThresh.Value.ToString(); | |
_lastScrollEvent = DateTime.Now; | |
var span = TimeSpan.FromSeconds(1); | |
await Task.Delay(span); | |
var delay = DateTime.Now - _lastScrollEvent; | |
if (delay < span) return; | |
DetectShape(); | |
} | |
private void trackBarUniquenessThreshold_Scroll(object sender, EventArgs e) | |
{ | |
DetectShapeAsync(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment