示例#1
0
        protected override void OnDetachedFromWindow()
        {
            if (mRendererHelper != null)
            {
                // Fix Java.Lang.IllegalMonitorStateException: 'object not locked by thread before wait()'
                // replace lock and wait() to CountDownLatch.

                /*lock (mRendererHelper)
                 * {
                 *      mRendererHelper.Shutdown();
                 *      try
                 *      {
                 *              mRendererHelper.Wait();
                 *      }
                 *      catch (Java.Lang.InterruptedException e)
                 *      {
                 *              Android.Util.Log.Error("CardboardView", "Interrupted during shutdown: " + e.ToString());
                 *      }
                 * }*/

                var latch = new Java.Util.Concurrent.CountDownLatch(1);
                mRendererHelper.Shutdown(latch);
                try
                {
                    latch.Await();
                }
                catch (Java.Lang.InterruptedException e)
                {
                    Android.Util.Log.Error("CardboardView", "Interrupted during shutdown: " + e.ToString());
                }
            }

            base.OnDetachedFromWindow();
        }
示例#2
0
 public void Shutdown(Java.Util.Concurrent.CountDownLatch latch)
 {
     mView.QueueEvent(() =>
     {
         mShuttingDown = true;
         mRenderer.OnRendererShutdown();
         latch.CountDown();
     });
 }