本文整理汇总了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();
}
}
示例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();
}
}
}
示例3: VirtualAlloc
public static IntPtr VirtualAlloc(
SafeHandle baseAddress,
UIntPtr size,
int allocationType,
int protection)
{
return Interop.mincore.VirtualAllocFromApp(baseAddress, size, allocationType, protection);
}
示例4: TransmitFile
internal static extern unsafe bool TransmitFile(
SafeHandle socket,
SafeHandle fileHandle,
int numberOfBytesToWrite,
int numberOfBytesPerSend,
SafeHandle overlapped,
TransmitFileBuffers* buffers,
TransmitFileOptions flags);
示例5: VirtualAlloc
public static IntPtr VirtualAlloc(
SafeHandle baseAddress,
UIntPtr size,
int allocationType,
int protection)
{
return Interop.Kernel32.VirtualAlloc(baseAddress, size, allocationType, protection);
}
示例6: DuplicateHandle
internal static extern bool DuplicateHandle(
SafeProcessHandle hSourceProcessHandle,
SafeHandle hSourceHandle,
SafeProcessHandle hTargetProcess,
out SafeWaitHandle targetHandle,
int dwDesiredAccess,
bool bInheritHandle,
int dwOptions
);
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}