本文整理汇总了C#中Microsoft.Win32.SafeHandles.SafeWaitHandle.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# SafeWaitHandle.Dispose方法的具体用法?C# SafeWaitHandle.Dispose怎么用?C# SafeWaitHandle.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Win32.SafeHandles.SafeWaitHandle
的用法示例。
在下文中一共展示了SafeWaitHandle.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMutexHandle
private static int CreateMutexHandle(bool initiallyOwned, string name, Win32Native.SECURITY_ATTRIBUTES securityAttribute, out SafeWaitHandle mutexHandle)
{
bool flag = false;
bool flag2 = false;
bool flag3 = false;
Label_0006:
flag2 = false;
flag3 = false;
mutexHandle = Win32Native.CreateMutex(securityAttribute, initiallyOwned, name);
int num = Marshal.GetLastWin32Error();
if (!mutexHandle.IsInvalid || (num != 5))
{
return num;
}
RuntimeHelpers.PrepareConstrainedRegions();
try
{
RuntimeHelpers.PrepareConstrainedRegions();
try
{
}
finally
{
Thread.BeginThreadAffinity();
flag = true;
}
mutexHandle = Win32Native.OpenMutex(0x100001, false, name);
if (!mutexHandle.IsInvalid)
{
num = 0xb7;
if (Environment.IsW2k3)
{
SafeWaitHandle handle = Win32Native.OpenMutex(0x100001, false, name);
if (!handle.IsInvalid)
{
RuntimeHelpers.PrepareConstrainedRegions();
try
{
uint num2 = 0;
IntPtr ptr = mutexHandle.DangerousGetHandle();
IntPtr ptr2 = handle.DangerousGetHandle();
IntPtr[] handles = new IntPtr[] { ptr, ptr2 };
num2 = Win32Native.WaitForMultipleObjects(2, handles, true, 0);
GC.KeepAlive(handles);
if (num2 == uint.MaxValue)
{
if (Marshal.GetLastWin32Error() != 0x57)
{
mutexHandle.Dispose();
flag3 = true;
}
}
else
{
flag2 = true;
if ((num2 >= 0) && (num2 < 2))
{
Win32Native.ReleaseMutex(mutexHandle);
Win32Native.ReleaseMutex(handle);
}
else if ((num2 >= 0x80) && (num2 < 130))
{
Win32Native.ReleaseMutex(mutexHandle);
Win32Native.ReleaseMutex(handle);
}
mutexHandle.Dispose();
}
goto Label_0166;
}
finally
{
handle.Dispose();
}
}
mutexHandle.Dispose();
flag3 = true;
}
}
else
{
num = Marshal.GetLastWin32Error();
}
}
finally
{
if (flag)
{
Thread.EndThreadAffinity();
}
}
Label_0166:
if ((flag2 || flag3) || (num == 2))
{
goto Label_0006;
}
if (num == 0)
{
num = 0xb7;
}
return num;
//.........这里部分代码省略.........