view Implab/ActionTask.cs @ 245:b904e0a3ba72 v3

working on promises
author cin
date Fri, 26 Jan 2018 04:13:34 +0300
parents eee3e49dd1ff
children
line wrap: on
line source

using System;

namespace Implab {
    public class ActionTask : ActionTaskBase, IResolvable {
        readonly Action m_task;
        public ActionTask(Action task, Action<Exception> error, Action<Exception> cancel, bool autoCancellable) : base(error,cancel, autoCancellable) {
            m_task = task;
        }

        public void Resolve() {
            if (m_task != null && LockCancelation()) {
                try {
                    m_task();
                    SetResult();
                } catch(Exception err) {
                    SetErrorInternal(err);
                }
            }
        }
    }
}