namespace System.Security.Principal {
-#if NET_2_0
[ComVisible (true)]
public class WindowsImpersonationContext : IDisposable {
-#else
- public class WindowsImpersonationContext {
-#endif
private IntPtr _token;
private bool undo;
}
undo = false;
}
-#if NET_2_0
[ComVisible (false)]
public void Dispose ()
{
if (!undo) {
Undo ();
}
- }
-#else
- ~WindowsImpersonationContext ()
- {
- if (!undo) {
- Undo ();
+ if (disposing){
+ // If we are explicitly disposed, we can avoid finalization.
+ GC.SuppressFinalize (this);
}
}
-#endif
+
public void Undo ()
{
if (!RevertToSelf ()) {