コード例 #1
0
    void OnGUI()
    {
        if (GUILayout.Button("Print Task"))
        {
            var t = new PrintTask();
            t.completionHandler = (task) => { Debug.Log("DONE with first"); };

            var t2 = new PrintTask();
            t2.completionHandler = (task) => { Debug.Log("DONE with second"); };

            t.nextTask = t2;

            P31TaskManager.instance.addTask(t);
        }


        if (GUILayout.Button("Action Task"))
        {
            _counter = 0;
            P31ActionTask.createAndStartTask(demoActionTask);
        }


        if (GUILayout.Button("Background Task"))
        {
            var t = new PrintInBackgroundTask();
            t.completionHandler = (task) =>
            {
                Debug.Log("[PrintInBackground] thread is bg? " + System.Threading.Thread.CurrentThread.IsBackground);
            };
            P31TaskManager.instance.addBackgroundTask(t);
        }
    }
コード例 #2
0
 public static P31ActionTask createAndStartTask( Func<bool> action, Action<P31AbstractTask> completionHandler )
 {
     var actionTask = new P31ActionTask( action );
     actionTask.completionHandler = completionHandler;
     P31TaskManager.instance.addTask( actionTask );
     return actionTask;
 }
コード例 #3
0
    public static P31ActionTask createAndStartTask(Func <bool> action, Action <P31AbstractTask> completionHandler)
    {
        var actionTask = new P31ActionTask(action);

        actionTask.completionHandler = completionHandler;
        P31TaskManager.instance.addTask(actionTask);
        return(actionTask);
    }