Exemplo n.º 1
0
        public static CancelableTask Create(Action <CancellationToken> action)
        {
            CancellationTokenSource source = new CancellationTokenSource();
            CancelableTask          task   = new CancelableTask(() => action(source.Token), source);

            return(task);
        }
Exemplo n.º 2
0
        public static CancelableTask Run(Action <CancellationToken> action)
        {
            CancelableTask task = Create(action);

            task.Start();
            return(task);
        }