view Implab/ActionTask.cs @ 154:2dcdee4c0810 v2

docs
author cin
date Fri, 12 Feb 2016 01:00:11 +0300
parents eb793fbbe4ea
children dd4a3590f9c6
line wrap: on
line source

using System;

namespace Implab {
    public class ActionTask : ActionTaskBase, IDeferred {
        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) {
                    HandleErrorInternal(err);
                }
            }
        }
    }
}