Merge branch 'new-songs-ui' of https://github.com/asesidaa/TaikoLocalServer into new-songs-ui
This commit is contained in:
commit
87dd13aa45
@ -63,6 +63,30 @@ public partial class Users
|
||||
}
|
||||
}
|
||||
|
||||
private CancellationTokenSource? cts;
|
||||
|
||||
private async Task Debounce(Func<Task> action, int delayInMilliseconds)
|
||||
{
|
||||
// Cancel the previous task
|
||||
cts?.Cancel();
|
||||
|
||||
// Create a new CancellationTokenSource
|
||||
cts = new CancellationTokenSource();
|
||||
|
||||
try
|
||||
{
|
||||
// Wait for the delay
|
||||
await Task.Delay(delayInMilliseconds, cts.Token);
|
||||
|
||||
// Execute the action
|
||||
await action();
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
// Ignore the exception
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnSearch(string search)
|
||||
{
|
||||
searchTerm = search;
|
||||
|
Loading…
x
Reference in New Issue
Block a user