diff options
Diffstat (limited to 'tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.cs')
-rw-r--r-- | tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.cs new file mode 100644 index 0000000000..0cd7db0cb1 --- /dev/null +++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + +class OpenMutexNeg +{ + public static int Main() + { + OpenMutexNeg omn = new OpenMutexNeg(); + return omn.Run(); + } + + private int Run() + { + int iRet = -1; + string sName = Common.GetUniqueName(); + // open a closed mutex + try + { + using (Mutex mut1 = new Mutex(false, sName)) {} + Mutex mut2 = Mutex.OpenExisting(sName); + } + catch (WaitHandleCannotBeOpenedException) + { + //Expected + iRet = 100; + } + catch (Exception e) + { + Console.WriteLine("Caught unexpected exception: " + + e.ToString()); + } + + Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed"); + return iRet; + } +}
\ No newline at end of file |