Few questions about c#
<p>Could anyone answer on these questions?</p>

<p>1) There is a Microsoft's class: <code>SafeHandle.cs</code> I looked into the source and there are such methods:  </p>

<pre><code>[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern void DangerousAddRef(ref bool success);
</code></pre>

<p>or</p>

<pre><code>[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern void DangerousRelease();
</code></pre>

<p>Where are the definitions of these method? Where Can I find them?</p>

<p>2) There is a method definitions which execute a method from the system library.</p>

<pre><code>[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail), SuppressUnmanagedCodeSecurity, DllImport("kernel32.dll", EntryPoint="WaitForSingleObject", SetLastError=true, ExactSpelling=true)]
private static extern int WaitForSingleObjectDontCallThis(SafeWaitHandle handle, int timeout);
</code></pre>

<p>Normally method: <code>WaitForSingleObject</code> accepts (HANDLE and DWORD).
How .net know how to obtain handle from the SafeWaitHandle class and how he does it?</p>
