1 回答

TA貢獻(xiàn)1854條經(jīng)驗(yàn) 獲得超8個(gè)贊
正如我在評(píng)論中提到的,您的 lambda for 不知道它是否在循環(huán)中被調(diào)用,因此沒有可用的。您需要 使用 來退出等待的任務(wù),以便您的代碼可以在等待的任務(wù)之后繼續(xù)。Dispatcher.InvokeAsynccontinuereturn
bool isNude = false;
var SearchTask = Task.Run(async () =>
{
foreach (var file in await GetFileListAsync(GlobalData.Config.DataPath))
{
isNude = false;
if (!ct.IsCancellationRequested)
{
await Dispatcher.InvokeAsync(() =>
{
if (ButtonNude.IsChecked == true)
{
foreach (var itemx in nudeData)
{
if (itemx.Equals(Path.GetFileNameWithoutExtension(file.FullName)))
{
isNude = true;
break;
}
}
}
if (isNude)
return; // continue -> return
// other code
}, DispatcherPriority.Background);
// <--- code continues here after return
}
}
}, ct);
- 1 回答
- 0 關(guān)注
- 91 瀏覽
添加回答
舉報(bào)