view Implab/ActionTask.cs @ 156:97fbbf816844 v2

Promises: SignalXXX methods merged into SignalHandler method. Components: RunnableComponent In progress
author cin
date Mon, 15 Feb 2016 04:22:15 +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);
                }
            }
        }
    }
}