您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
34 行
771 B
34 行
771 B
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace HuaweiAuthDemo
|
|
{
|
|
internal class UnityMainThread : MonoBehaviour
|
|
{
|
|
internal static UnityMainThread instance;
|
|
ConcurrentQueue<Action> jobs = new ConcurrentQueue<Action>();
|
|
|
|
void Awake() {
|
|
instance = this;
|
|
}
|
|
|
|
void Update() {
|
|
while (jobs.Count > 0)
|
|
{
|
|
Action currentJob;
|
|
jobs.TryDequeue(out currentJob);
|
|
if (currentJob != null)
|
|
{
|
|
currentJob.Invoke();
|
|
}
|
|
}
|
|
}
|
|
|
|
internal void AddJob(Action newJob) {
|
|
jobs.Enqueue(newJob);
|
|
}
|
|
}
|
|
|
|
}
|