[corlib] Parse datetime string using culture calendar. Fixes #18052
[mono.git] / mcs / class / corlib / System.Runtime.InteropServices / CriticalHandle.cs
index 479dc4480d6c657ed7f0defd452ba40ff7bb5a55..ce50aff31b497782d36b4cbc5bc7e6b382aee63a 100644 (file)
@@ -47,17 +47,14 @@ namespace System.Runtime.InteropServices
                        if (_disposed)
                                return;
 
-                       _disposed = true;
-                       if (IsInvalid)
-                               return;
-
-                       if (disposing == true && !IsInvalid){
-                               if (!ReleaseHandle ()) {
+                       if (!IsInvalid){
+                               if (!_disposed && !ReleaseHandle ()) {
                                        GC.SuppressFinalize (this);
                                } else {
                                        // Failed in release...
                                }
                        }
+                       _disposed = true;
                }
 
                [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]