public static Task ToTask(this IAsyncHandleWrapper wrapper) { return(Task.Run(() => { while (!wrapper.IsDone) { Thread.Sleep(1); } wrapper.OnComplete(); })); }
public void Request(IAsyncHandleWrapper wrapper) { if (nowState != LoadState.Ready) { if (nowState != LoadState.Working) { throw new InvalidOperationException("准备,工作状态才能添加请求"); } _requestQueue.Enqueue(wrapper); } else { _requestQueue.Enqueue(wrapper); } }