本文整理汇总了C#中SafeHandle.DangerousGetHandle方法的典型用法代码示例。如果您正苦于以下问题:C# SafeHandle.DangerousGetHandle方法的具体用法?C# SafeHandle.DangerousGetHandle怎么用?C# SafeHandle.DangerousGetHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SafeHandle
的用法示例。
在下文中一共展示了SafeHandle.DangerousGetHandle方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
}
示例2: GetIPv6MulticastOption
internal static unsafe Error GetIPv6MulticastOption(SafeHandle socket, MulticastOption multicastOption, IPv6MulticastOption* option)
{
bool release = false;
try
{
socket.DangerousAddRef(ref release);
return DangerousGetIPv6MulticastOption((int)socket.DangerousGetHandle(), multicastOption, option);
}
finally
{
if (release)
{
socket.DangerousRelease();
}
}
}
示例3: 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();
}
}
}
示例4: 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();
}
}
}
示例5: 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();
}
}
}
示例6: 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();
}
}
}
示例7: 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();
}
}
}
示例8: 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();
}
}
}
示例9: 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();
}
}
}
示例10: 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();
}
}
}
示例11: 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();
}
}
}
示例12: Listen
internal static Error Listen(SafeHandle socket, int backlog)
{
bool release = false;
try
{
socket.DangerousAddRef(ref release);
return DangerousListen((int)socket.DangerousGetHandle(), backlog);
}
finally
{
if (release)
{
socket.DangerousRelease();
}
}
}
示例13: GetProcessRuntimes
public static IEnumerable<string> GetProcessRuntimes(ICLRMetaHost host, SafeHandle hProcess)
{
if (host != null)
{
var buffer = new StringBuilder(1024);
IEnumUnknown ppEnumerator = host.EnumerateLoadedRuntimes(hProcess.DangerousGetHandle());
return ppEnumerator.Cast<ICLRRuntimeInfo>().Select(rti =>
{
var bufferLength = (uint)buffer.Capacity;
rti.GetVersionString(buffer, ref bufferLength);
return buffer.ToString(0, (int)bufferLength - 1);
}).ToList();
}
else
{
string buffer = GetVersionFromProcess(hProcess);
if (buffer != null)
{
return new[] { buffer };
}
}
return Enumerable.Empty<string>();
}