public IThreadPoolResult<T> QueueUserWorkItem<T>(Func<T> action) { var result = new ThreadPoolResult<T>(); #if !UNITY_WEBGL ThreadPool.QueueUserWorkItem(sender => #endif { try { T data = default; #if UNITY_WEBGL _dispatcher.Dispatch(() => { data = action(); }); #else data = action(); #endif _dispatcher.Dispatch(() => result.Resolve(data)); } catch (Exception exception) { _dispatcher.Dispatch(() => result.Resolve(exception)); } } #if !UNITY_WEBGL ); #endif return result; }
public IThreadPoolResult QueueUserWorkItem(Action action) { var result = new ThreadPoolResult(); #if !UNITY_WEBGL ThreadPool.QueueUserWorkItem(sender => #endif { try { #if UNITY_WEBGL _dispatcher.Dispatch(action); #else action(); #endif _dispatcher.Dispatch(result.Resolve); } catch (Exception exception) { _dispatcher.Dispatch(() => result.Resolve(exception)); } } #if !UNITY_WEBGL ); #endif return result; }