예제 #1
0
 internal static void FreeArgs(JavaVMAttachArgs args)
 {
     args.Dispose();
 }
예제 #2
0
파일: JavaVM.cs 프로젝트: tottty/csjni
 internal static IntPtr AttachCurrentThread(JavaVMThreadAttachArguments arguments)
 {
     JavaVMAttachArgs attachArgs = new JavaVMAttachArgs();
     if (arguments != null)
     {
         attachArgs = arguments.ToArgs(Instance.JvmConfiguration.Version);
     }
     try
     {
         unsafe
         {
             void** ppEnv = null;
             void* pArgs = null;
             if (arguments != null)
             {
                 pArgs = &attachArgs;
             }
             int result = Instance.mInvokeInterface.AttachCurrentThread(Instance.mJavaVM, &ppEnv, pArgs);
             if (0 != result)
             {
                 JniException.CheckVMErrorCode(result);
             }
             IntPtr environmentHandle = new IntPtr((void*)ppEnv);
             return environmentHandle;
         }
     }
     finally
     {
         if (arguments != null)
         {
             JavaVMThreadAttachArguments.FreeArgs(attachArgs);
         }
     }
 }