diff options
Diffstat (limited to 'tests/src/baseservices/regression/v1/threads/functional/threadpool/cs_threadpoolnullchecks/cs_threadpoolnullchecks.cs')
-rw-r--r-- | tests/src/baseservices/regression/v1/threads/functional/threadpool/cs_threadpoolnullchecks/cs_threadpoolnullchecks.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/src/baseservices/regression/v1/threads/functional/threadpool/cs_threadpoolnullchecks/cs_threadpoolnullchecks.cs b/tests/src/baseservices/regression/v1/threads/functional/threadpool/cs_threadpoolnullchecks/cs_threadpoolnullchecks.cs new file mode 100644 index 0000000000..ccb56485db --- /dev/null +++ b/tests/src/baseservices/regression/v1/threads/functional/threadpool/cs_threadpoolnullchecks/cs_threadpoolnullchecks.cs @@ -0,0 +1,49 @@ +// 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.Security; +using System.Threading; + +#if WINCORESYS +[assembly:AllowPartiallyTrustedCallers] +#endif + +public class CS_ThreadPoolNullChecks { + public static void EventSig(Object state, bool wasSignalled) { + Console.WriteLine("In EventSig: {0}.", Thread.CurrentThread.GetHashCode()); + Console.WriteLine("wasSignalled: " + wasSignalled); + } + public static int Main(String [] args) { + Console.WriteLine("CS_ThreadPoolNullChecks ..."); + int ret = 100; + ManualResetEvent j = new ManualResetEvent(false); + try { + ThreadPool.RegisterWaitForSingleObject(null,new WaitOrTimerCallback(EventSig),null,20,false); + ret = 0; // Fail + } + catch (ArgumentNullException) { + } + try { + ThreadPool.RegisterWaitForSingleObject(null,null,null,20,false); + ret = 0; // Fail + } + catch (ArgumentNullException) { + } + try { + ThreadPool.RegisterWaitForSingleObject(j,null,null,20,false); + ret = 0; // Fail + } + catch (ArgumentNullException) { + } + try { + ThreadPool.QueueUserWorkItem(null); + Console.WriteLine("ThreadPool.QueueUserWorkItem(null) should have thrown an Exception!"); + ret = 0; // Fail + } + catch (ArgumentNullException) { + } + Console.WriteLine(" ... CS_ThreadPoolNullChecks (ret == {0})",ret); + return ret; + } +}
\ No newline at end of file |