Exemple #1
0
        public static DialogResult Show(string text)
        {
            if (!Disable)
            {
                var gameRunner = GameRunner.Singleton;
                var activity   = gameRunner.Activity;
                if (gameRunner.InModal || activity == null ||
                    android.os.Looper.getMainLooper().getThread()
                    == java.lang.Thread.currentThread())
                {
                    GameRunner.Log(text);
                }
                else
                {
                    gameRunner.PauseGame(true);

                    var waitObj = new android.os.ConditionVariable();
                    Show(activity, text, (_) => waitObj.open());
                    waitObj.block();

                    gameRunner.ResumeGame(true);
                }
            }
            return(DialogResult.OK);
        }
Exemple #2
0
        //
        // CanResume
        //

        public static bool CanResume(android.app.Activity activity)
        {
            foreach (var renderer in GetRenderersForActivity(activity))
            {
                if (renderer.paused.get() != 0)
                {
                    // we cannot use waitObject for resuming, because the surface
                    // may have been destroyed between pause and resume, in which
                    // case onDrawFrame would not get called.

                    var cond = new android.os.ConditionVariable();
                    renderer.surface.queueEvent(((java.lang.Runnable.Delegate)(
                                                     () => cond.open())).AsInterface());

                    renderer.surface.onResume();
                    if (!cond.block(2000))
                    {
                        // something is wrong if the queued event did not run
                        return(false);
                    }

                    if (!renderer.paused.compareAndSet(1, 0))
                    {
                        // cannot resume because we lost the GL context,
                        // see also PauseRenderers and onSurfaceCreated
                        return(false);
                    }
                }
            }
            return(true);
        }