Update copyrights
[mono.git] / mcs / class / corlib / System.Threading / ManualResetEventSlim.cs
index 3500f85554dfc6fd31a5381f1a230a0141116784..50debca78cc0e845cdae348004ad41dc25867e98 100644 (file)
 //
 //
 
-#if NET_4_0
+#if NET_4_0 || MOBILE
 
 using System;
 
 namespace System.Threading
 {
+       [System.Diagnostics.DebuggerDisplayAttribute ("Set = {IsSet}")]
        public class ManualResetEventSlim : IDisposable
        {
                const int isSet    = 1;
@@ -141,10 +142,19 @@ namespace System.Threading
 
                public WaitHandle WaitHandle {
                        get {
-                               if (handle != null)
+                               if (handle != null) {
+                                       if (state == isSet)
+                                               handle.Set ();
+
                                        return handle;
-                               return LazyInitializer.EnsureInitialized (ref handle,
-                                                                         () => new ManualResetEvent (state == isSet ? true : false));
+                               }
+
+                               var result = LazyInitializer.EnsureInitialized (ref handle,
+                                                                               () => new ManualResetEvent (state == isSet ? true : false));
+                               if (state == isSet)
+                                       result.Set ();
+
+                               return result;
                        }
                }