System.Threading.SemaphoreSlim.WaitAsync().
authorMartin Baulig <martin.baulig@xamarin.com>
Tue, 12 Mar 2013 19:28:35 +0000 (15:28 -0400)
committerMartin Baulig <martin.baulig@xamarin.com>
Wed, 13 Mar 2013 01:15:56 +0000 (21:15 -0400)
mcs/class/corlib/System.Threading/SemaphoreSlim.cs

index a48aec779bcca568792307b8ab51fb174c18603a..3b63c4231d6ae2446f4f3c5af56fe0d6f57e0f8f 100644 (file)
@@ -24,6 +24,9 @@
 
 using System;
 using System.Diagnostics;
+#if NET_4_5
+using System.Threading.Tasks;
+#endif
 
 #if NET_4_0
 namespace System.Threading
@@ -183,6 +186,39 @@ namespace System.Threading
                                return handle;
                        }
                }
+
+#if NET_4_5
+               public Task WaitAsync ()
+               {
+                       return Task.Factory.StartNew (() => Wait ());
+               }
+
+               public Task WaitAsync (CancellationToken cancellationToken)
+               {
+                       return Task.Factory.StartNew (() => Wait (cancellationToken), cancellationToken);
+               }
+
+               public Task<bool> WaitAsync (int millisecondsTimeout)
+               {
+                       return Task.Factory.StartNew (() => Wait (millisecondsTimeout));
+               }
+
+               public Task<bool> WaitAsync (TimeSpan timeout)
+               {
+                       return Task.Factory.StartNew (() => Wait (timeout));
+               }
+
+               public Task<bool> WaitAsync (int millisecondsTimeout, CancellationToken cancellationToken)
+               {
+                       return Task.Factory.StartNew (() => Wait (millisecondsTimeout, cancellationToken), cancellationToken);
+               }
+
+               public Task<bool> WaitAsync (TimeSpan timeout, CancellationToken cancellationToken)
+               {
+                       return Task.Factory.StartNew (() => Wait (timeout, cancellationToken), cancellationToken);
+               }
+#endif
+
        }
 }
 #endif