您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
25 行
996 B
25 行
996 B
using System.Threading;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.Services.Lobbies.Scheduler
|
|
{
|
|
// "inspired" by UniTask
|
|
public static class ThreadHelper
|
|
{
|
|
public static SynchronizationContext SynchronizationContext => _unitySynchronizationContext;
|
|
public static System.Threading.Tasks.TaskScheduler TaskScheduler => _taskScheduler;
|
|
public static int MainThreadId => _mainThreadId;
|
|
|
|
private static SynchronizationContext _unitySynchronizationContext;
|
|
private static System.Threading.Tasks.TaskScheduler _taskScheduler;
|
|
private static int _mainThreadId;
|
|
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
|
public static void Init()
|
|
{
|
|
_unitySynchronizationContext = SynchronizationContext.Current;
|
|
_taskScheduler = System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext();
|
|
_mainThreadId = Thread.CurrentThread.ManagedThreadId;
|
|
}
|
|
}
|
|
}
|