示例#1
0
        public static void PollOnUpdateUntilComplete(Func <bool> condition)
        {
            object obj = RunOnMainThread.pollingJobs;

            lock (obj)
            {
                RunOnMainThread.pollingJobs.Add(condition);
            }
            if (RunOnMainThread.ExecuteNow && RunOnMainThread.OnMainThread)
            {
                RunOnMainThread.RunAction(delegate
                {
                    while (true)
                    {
                        RunOnMainThread.ExecuteAll();
                        object obj2 = RunOnMainThread.pollingJobs;
                        lock (obj2)
                        {
                            if (RunOnMainThread.pollingJobs.Count == 0)
                            {
                                break;
                            }
                        }
                        Thread.Sleep(100);
                    }
                });
            }
        }
示例#2
0
 public static bool TryExecuteAll()
 {
     if (RunOnMainThread.OnMainThread)
     {
         RunOnMainThread.ExecuteAll();
         return(true);
     }
     return(false);
 }
示例#3
0
        public static void Run(Action job, bool runNow = true)
        {
            object obj = RunOnMainThread.jobs;
            bool   flag;

            lock (obj)
            {
                flag = (RunOnMainThread.jobs.Count == 0);
                RunOnMainThread.jobs.Enqueue(job);
            }
            if ((flag || RunOnMainThread.ExecuteNow) && runNow && RunOnMainThread.OnMainThread)
            {
                RunOnMainThread.ExecuteAll();
            }
        }