public static bool RunAsync(DateTime timeout, Action action, Func <bool> check_completed)
        {
            var vc   = new AsyncController(action);
            var bckp = window.RootViewController;

            window.RootViewController = vc;
            try {
                do
                {
                    if (timeout < DateTime.Now)
                    {
                        return(false);
                    }
                    NSRunLoop.Main.RunUntil(NSDate.Now.AddSeconds(0.1));
                } while (!check_completed());
            } finally {
                window.RootViewController = bckp;
            }

            return(true);
        }
Exemple #2
0
        public static bool RunAsync(DateTime timeout, Action action, Func <bool> check_completed, UIImage imageToShow = null)
        {
            var vc         = new AsyncController(action, imageToShow);
            var bckp       = window.RootViewController;
            var navigation = bckp as UINavigationController;

            if (navigation != null)
            {
                navigation.PushViewController(vc, false);
            }
            else
            {
                window.RootViewController = vc;
            }

            try {
                do
                {
                    if (timeout < DateTime.Now)
                    {
                        return(false);
                    }
                    NSRunLoop.Main.RunUntil(NSDate.Now.AddSeconds(0.1));
                } while (!check_completed());
            } finally {
                if (navigation != null)
                {
                    navigation.PopViewController(false);
                }
                else
                {
                    window.RootViewController = bckp;
                }
            }

            return(true);
        }