当前位置: 首页>>代码示例>>C#>>正文


C# SafeHandle类代码示例

本文整理汇总了C#中SafeHandle的典型用法代码示例。如果您正苦于以下问题:C# SafeHandle类的具体用法?C# SafeHandle怎么用?C# SafeHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SafeHandle类属于命名空间,在下文中一共展示了SafeHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckValidOpenSslHandle

 internal static void CheckValidOpenSslHandle(SafeHandle handle)
 {
     if (handle == null || handle.IsInvalid)
     {
         throw CreateOpenSslCryptographicException();
     }
 }
开发者ID:rainersigwald,项目名称:corefx,代码行数:7,代码来源:Interop.ERR.cs

示例2: Poll

        /// <summary>
        /// Polls a File Descriptor for the passed in flags.
        /// </summary>
        /// <param name="fd">The descriptor to poll</param>
        /// <param name="events">The events to poll for</param>
        /// <param name="timeout">The amount of time to wait; -1 for infinite, 0 for immediate return, and a positive number is the number of milliseconds</param>
        /// <param name="triggered">The events that were returned by the poll call. May be PollEvents.POLLNONE in the case of a timeout.</param>
        /// <returns>An error or Error.SUCCESS.</returns>
        internal static unsafe Error Poll(SafeHandle fd, PollEvents events, int timeout, out PollEvents triggered)
        {
            bool gotRef = false;
            try
            {
                fd.DangerousAddRef(ref gotRef);

                var pollEvent = new PollEvent
                {
                    FileDescriptor = fd.DangerousGetHandle().ToInt32(),
                    Events = events,
                };

                uint unused;
                Error err = Poll(&pollEvent, 1, timeout, &unused);
                triggered = pollEvent.TriggeredEvents;
                return err;
            }
            finally
            {
                if (gotRef)
                {
                    fd.DangerousRelease();
                }
            }
        }
开发者ID:Czapek83,项目名称:corefx,代码行数:34,代码来源:Interop.Poll.cs

示例3: VirtualAlloc

 public static IntPtr VirtualAlloc(
         SafeHandle baseAddress,
         UIntPtr size,
         int allocationType,
         int protection)
 {
     return Interop.mincore.VirtualAllocFromApp(baseAddress, size, allocationType, protection);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:8,代码来源:Interop.Windows.NETCore50.cs

示例4: TransmitFile

 internal static extern unsafe bool TransmitFile(
     SafeHandle socket,
     SafeHandle fileHandle,
     int numberOfBytesToWrite,
     int numberOfBytesPerSend,
     SafeHandle overlapped,
     TransmitFileBuffers* buffers,
     TransmitFileOptions flags);
开发者ID:chcosta,项目名称:corefx,代码行数:8,代码来源:Interop.TransmitFile.cs

示例5: VirtualAlloc

 public static IntPtr VirtualAlloc(
         SafeHandle baseAddress,
         UIntPtr size,
         int allocationType,
         int protection)
 {
     return Interop.Kernel32.VirtualAlloc(baseAddress, size, allocationType, protection);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:Interop.Windows.cs

示例6: DuplicateHandle

 internal static extern bool DuplicateHandle(
     SafeProcessHandle hSourceProcessHandle,
     SafeHandle hSourceHandle,
     SafeProcessHandle hTargetProcess,
     out SafeWaitHandle targetHandle,
     int dwDesiredAccess,
     bool bInheritHandle,
     int dwOptions
 );
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:Interop.DuplicateHandle_SafeProcessHandle.cs

示例7: GetBytesAvailable

 internal static unsafe Error GetBytesAvailable(SafeHandle socket, int* available)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousGetBytesAvailable((int)socket.DangerousGetHandle(), available);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.GetBytesAvailable.cs

示例8: GetSocketErrorOption

 internal static unsafe Error GetSocketErrorOption(SafeHandle socket, Error* socketError)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousGetSocketErrorOption((int)socket.DangerousGetHandle(), socketError);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.GetSocketErrorOption.cs

示例9: SendMessage

 internal static unsafe Error SendMessage(SafeHandle socket, MessageHeader* messageHeader, SocketFlags flags, long* sent)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousSendMessage((int)socket.DangerousGetHandle(), messageHeader, flags, sent);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.SendMessage.cs

示例10: SetSockOpt

 internal static unsafe Error SetSockOpt(SafeHandle socket, SocketOptionLevel optionLevel, SocketOptionName optionName, byte* optionValue, int optionLen)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousSetSockOpt((int)socket.DangerousGetHandle(), optionLevel, optionName, optionValue, optionLen);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.SetSockOpt.cs

示例11: GetSockName

 internal static unsafe Error GetSockName(SafeHandle socket, byte* socketAddress, int* socketAddressLen)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousGetSockName((int)socket.DangerousGetHandle(), socketAddress, socketAddressLen);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.GetSockName.cs

示例12: SetReceiveTimeout

 internal static unsafe Error SetReceiveTimeout(SafeHandle socket, int millisecondsTimeout)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousSetReceiveTimeout((int)socket.DangerousGetHandle(), millisecondsTimeout);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.SetReceiveTimeout.cs

示例13: Shutdown

 internal static Error Shutdown(SafeHandle socket, SocketShutdown how)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousShutdown((int)socket.DangerousGetHandle(), how);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.Shutdown.cs

示例14: TryChangeSocketEventRegistration

 internal static Error TryChangeSocketEventRegistration(int port, SafeHandle socket, SocketEvents currentEvents, SocketEvents newEvents, IntPtr data)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousTryChangeSocketEventRegistration(port, (int)socket.DangerousGetHandle(), currentEvents, newEvents, data);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.SocketEvent.cs

示例15: Accept

 internal static unsafe Error Accept(SafeHandle socket, byte* socketAddress, int* socketAddressLen, int* acceptedFd)
 {
     bool release = false;
     try
     {
         socket.DangerousAddRef(ref release);
         return DangerousAccept((int)socket.DangerousGetHandle(), socketAddress, socketAddressLen, acceptedFd);
     }
     finally
     {
         if (release)
         {
             socket.DangerousRelease();
         }
     }
 }
开发者ID:benpye,项目名称:corefx,代码行数:16,代码来源:Interop.Accept.cs


注:本文中的SafeHandle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。