public partial class Page1 { public Page1() { this.InitializeComponent(); this.Entry.TextChanged += this.EntryOnTextChanged; }
private CancellationTokenSource throttleCts = new CancellationTokenSource();
private void EntryOnTextChanged(object sender, TextChangedEventArgs args) {
Interlocked.Exchange(ref this.throttleCts, new CancellationTokenSource()).Cancel(); Task.Delay(TimeSpan.FromMilliseconds(500), this.throttleCts.Token)
.ContinueWith( delegate { this.HandleString(this.Entry.Text); }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext()); }
private void HandleString(string str) { }