//
//
-#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;
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;
}
}