您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
26 行
696 B
26 行
696 B
using System;
|
|
using System.Collections.Generic;
|
|
using UIWidgets.foundation;
|
|
using UnityEngine;
|
|
|
|
namespace UIWidgets.async {
|
|
public class MicrotaskQueue {
|
|
private Queue<Action> _queue = new Queue<Action>();
|
|
|
|
public void scheduleMicrotask(Action action) {
|
|
this._queue.Enqueue(action);
|
|
}
|
|
|
|
public void flushMicrotasks() {
|
|
while (this._queue.isNotEmpty()) {
|
|
var action = this._queue.Dequeue();
|
|
try {
|
|
action();
|
|
}
|
|
catch (Exception ex) {
|
|
Debug.LogError("Error to execute microtask: " + ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|