Ejemplo n.º 1
0
        public Task <T> StartNew <T>(Func <T> func)
        {
            var tcs = new TaskCompletionSource <T>();

            scheduler.Post(() => {
                try {
                    tcs.SetResult(func());
                } catch (Exception e) {
                    tcs.SetException(e);
                }
            });
            return(tcs.Task);
        }