using CommonLang.Concurrent; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ZeusServerNode { public class SingleThreadTaskExecutor : IDisposable { private SingleThreadExecutor executor = new SingleThreadExecutor(); public void Dispose() { executor.Shutdown(); } public Task Run(Func function) { Task ret = new Task(function); executor.Execute(() => { ret.RunSynchronously(); }); return ret; } } }