private async Task listAsync() { if (_cts != null) { _cts.Cancel(); } _cts = new CancellationTokenSource(); lbList.Items.Clear(); var di = new DirectoryInfoEx(tbFolder.Text); foreach (var item in await di.GetFilesAsync("*", cbRecrusive.IsChecked.Value ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly, _cts.Token)) { lbList.Items.Add(item); } }