コード例 #1
0
        private void RpcEntryPoint2(IntPtr pAsyncState, IntPtr clientHandle, uint szInput, IntPtr input, IntPtr szOutput, IntPtr output)
        {
            try
            {
                byte[] bytesIn = new byte[szInput];
                Marshal.Copy(input, bytesIn, 0, bytesIn.Length);
                var asyncContext = new AsyncContextImpl(pAsyncState, szOutput, output);
                try
                {
                    using (RpcClientInfo client = new RpcClientInfo(clientHandle))
                    {
                        ExecuteAsync(client, asyncContext, bytesIn);
                    }
                }
                catch (Exception e)
                {
                    if (asyncContext.status == AsyncContextStatus.InProgress)
                    {
                        asyncContext.completeCall((uint)RpcError.RPC_E_FAIL);
                    }
                }
            }
            catch (Exception ex)
            {
                if (IntPtr.Zero != output)
                {
                    RpcApi.Free(Marshal.ReadIntPtr(output));
                }
                Marshal.WriteIntPtr(output, IntPtr.Zero);
                Marshal.WriteInt32(szOutput, 0);

                Log.Error(ex);

                var result = (IntPtr)RpcError.RPC_E_FAIL;
                RpcApi.RpcAsyncCompleteCall(pAsyncState, ref result);
                return;
            }
        }
コード例 #2
0
        private void RpcEntryPoint2(IntPtr pAsyncState, IntPtr clientHandle, uint szInput, IntPtr input, IntPtr szOutput, IntPtr output)
        {
            try
              {
            byte[] bytesIn = new byte[szInput];
            Marshal.Copy(input, bytesIn, 0, bytesIn.Length);
            var asyncContext = new AsyncContextImpl(pAsyncState, szOutput, output);
            try
            {
              using (RpcClientInfo client = new RpcClientInfo(clientHandle))
              {
            ExecuteAsync(client, asyncContext, bytesIn);
              }
            }
            catch (Exception e)
            {
              if (asyncContext.status == AsyncContextStatus.InProgress)
              {
            asyncContext.completeCall((uint) RpcError.RPC_E_FAIL);
              }
            }
              }
              catch (Exception ex)
              {
            if (IntPtr.Zero != output)
            {
              RpcApi.Free(Marshal.ReadIntPtr(output));
            }
            Marshal.WriteIntPtr(output, IntPtr.Zero);
            Marshal.WriteInt32(szOutput, 0);

            Log.Error(ex);

            var result = (IntPtr) RpcError.RPC_E_FAIL;
            RpcApi.RpcAsyncCompleteCall(pAsyncState, ref result);
            return;
              }
        }