コード例 #1
0
    /// <summary>
    /// Starts a task in a new thread, and runs a task in the main thread after it has finished.
    /// </summary>
    /// <param name="calculate">Function that will be run on the new thread.
    /// Has to take in and return an object.</param>
    /// <param name="callback">Function that is run in the main thread after the calculation has finished
    /// Takes an object parameter (the results of the calculation). Returns void.</param>
    /// <param name="o">An object that is passed to the calculation function.</param>
    public void StartTask(Func <object, object> calculate, Action <object> callback, object o = null)
    {
        this.calculate = calculate;
        this.callback  = callback;
        this.input     = o;

        ThreadTaskPool.QueueTask(this);
    }
コード例 #2
0
 public IEnumerator WaitForCallback()
 {
     while (!IsDone)
     {
         yield return(null);
     }
     ThreadTaskPool.FinishTask(this);
     callback(results);
 }