Esempio n. 1
0
 public ProgressForm(string title, DoWorkCallback work, Action <RunWorkerCompletedEventArgs> finish)
 {
     InitializeComponent();
     Text = title;
     MainWorker.DoWork             += (object sender, DoWorkEventArgs e) => { e.Cancel = !work(MainWorker); };
     MainWorker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) => { Close(); finish(e); };
     MainWorker.RunWorkerAsync();
 }
Esempio n. 2
0
        public static BackgroundThread <T> RunAsync(T parameter,
                                                    DoWorkCallback <T> doWork,
                                                    SuccessCallback success,
                                                    ErrorCallback error)
        {
            BackgroundThread <T> thread = new BackgroundThread <T>();

            thread._doWork  = doWork;
            thread._success = success;
            thread._error   = error;
            thread._worker.RunWorkerAsync(parameter);
            return(thread);
        }
Esempio n. 3
0
    /// <summary>
    /// Queue up a new callback to be executed on Update after others finish.
    /// The callback should return 'true' if it's done, or 'false' if it needs more time.
    /// </summary>
    static public void Add(MonoBehaviour mb, DoWorkCallback callback)
    {
        if (mb == null)
        {
            return;
        }

        if (mInstance == null)
        {
            GameObject go = new GameObject("_WorkQueue");
            mInstance = go.AddComponent <WorkQueue>();
            DontDestroyOnLoad(go);
        }

        Entry ent = new Entry();

        ent.mb       = mb;
        ent.callback = callback;
        mInstance.mList.Add(ent);
    }