/**
 * 异步等待
 * @param ms 等待毫秒数
 * @param value 等待完成后返回的值
 * @returns 
 */
export function AsyncDelay<T>(ms: number, value?: T) {
    return new Promise<T>((resolve) => setTimeout(resolve, ms, value));
}

export async function AsyncWaitUntil(predicate: () => boolean, waitTime = 100) {
    while (!predicate()) {
        await AsyncDelay(waitTime);
    }
}