private void ReleaseCore(bool appDomainUnloading) { lock (mLockingObject) { if (Instance == null) { return; } GC.WaitForPendingFinalizers(); if (appDomainUnloading) { AppDomain.CurrentDomain.ProcessExit -= new EventHandler(CurrentDomain_ProcessExit); AppDomain.CurrentDomain.DomainUnload -= new EventHandler(CurrentDomain_DomainUnload); } if (appDomainUnloading && mPinnedDelegates != null) { foreach (DelegatePin pin in mPinnedDelegates.Values) { ((IDisposable)pin).Dispose(); } mPinnedDelegates.Clear(); mPinnedDelegates = null; } mNativeMethodRegistrar = null; try { if (appDomainUnloading) { DetachCurrentThread(); } if (appDomainUnloading && !AllowReuseOfExistingVM && this.mJavaVM != IntPtr.Zero) { //DestroyJavaVM(); } } catch (JniException) { } finally { mJavaVM = IntPtr.Zero; } JniEnvironment.Release(); mInstance = null; PlatformFactory.Platform.Release(); } }
private static void StaticInitializeCore(JavaVMConfiguration configuration, IJavaVMCallbackHandler hookHandler) { if (Instance != null) { throw new JniException(JniResourceManager.Instance.GetString("jvmCoreInitOnlyOnce")); } mInstance = new JavaVM(); Instance.InitializeCore(configuration, hookHandler); }