예제 #1
0
        protected virtual void Dispose(bool disposing)
        {
            // free native resources if there are any.
            if (javaClass != IntPtr.Zero)
            {
                env.DeleteGlobalRef(javaClass);
                javaClass = IntPtr.Zero;
            }

            if (javaObject != IntPtr.Zero)
            {
                env.DeleteLocalRef(javaObject);
                javaObject = IntPtr.Zero;
            }

            if (disposing)
            {
                // free managed resources
                if (jvm != null)
                {
                    jvm.Dispose();
                    jvm = null;
                }

                if (env != null)
                {
                    env.Dispose();
                    env = null;
                }
            }
        }
예제 #2
0
        protected virtual void Dispose(bool disposing)
        {
            // free native resources if there are any.
            foreach (KeyValuePair <string, IntPtr> javaClass in usedClasses)
            {
                if (javaClass.Value != IntPtr.Zero)
                {
                    env.DeleteGlobalRef(javaClass.Value);
                    usedClasses[javaClass.Key] = IntPtr.Zero;
                }
            }
            for (int i = 0, end = usedObject.Count; i < end; ++i)
            {
                IntPtr javaObject = usedObject[i];
                if (javaObject != IntPtr.Zero)
                {
                    env.DeleteLocalRef(javaObject);
                    usedObject[i] = IntPtr.Zero;
                }
            }

            if (disposing)
            {
                // free managed resources
                if (jvm != null)
                {
                    jvm.Dispose();
                    jvm = null;
                }

                if (env != null)
                {
                    env.Dispose();
                    env = null;
                }
            }
        }