赞
踩
异步等待的取消,是一个很重要的事情,那么UniTask中如何取消WhenAny和WhenAll的异步等待呢?
public async UniTask FlowAsync(CancellationToken ctk)
{
var allTasks = scripts.Select(s => (s as IFlowAsync).FlowAsync(ctk));
await UniTask.WhenAll(allTasks).AttachExternalCancellation(ctk);
await UniTask.WhenAny(allTasks).AttachExternalCancellation(ctk);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。