Open source tests from baseservices/threading.
authorAditya Mandaleeka <adityam@microsoft.com>
Thu, 3 Mar 2016 20:24:52 +0000 (12:24 -0800)
committerAditya Mandaleeka <adityam@microsoft.com>
Thu, 3 Mar 2016 20:24:52 +0000 (12:24 -0800)
228 files changed:
tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.cs [new file with mode: 0644]
tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.csproj [new file with mode: 0644]
tests/src/baseservices/threading/commitstackonlyasneeded/DisablePreCommit.exe.config [new file with mode: 0644]
tests/src/baseservices/threading/commitstackonlyasneeded/EnablePreCommit.exe.config [new file with mode: 0644]
tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs [new file with mode: 0644]
tests/src/baseservices/threading/commitstackonlyasneeded/project.json [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.cs [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.csproj [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.cs [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.csproj [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.cs [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.csproj [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.cs [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.csproj [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.cs [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.csproj [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.cs [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.csproj [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.cs [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.csproj [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.cs [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.csproj [new file with mode: 0644]
tests/src/baseservices/threading/coverage/Nullref/project.json [new file with mode: 0644]
tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/AutoResetEvent/project.json [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/project.json [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/project.json [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/NamedCommon.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/EventWaitHandleTest.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/EventWaitHandle/unit/project.json [new file with mode: 0644]
tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.cs [new file with mode: 0644]
tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.csproj [new file with mode: 0644]
tests/src/baseservices/threading/events/ManualResetEvent/project.json [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit01.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit01.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit02.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit02.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit03.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit03.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit04.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit04.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit05.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit05.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit06.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit06.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit07.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit07.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit08.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit08.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit09.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit09.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit10.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit10.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit11.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit11.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit12.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit12.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit13.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit13.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit14.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit14.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit15.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/EnterExit15.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/MonitorHelper.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter01.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter01.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter03.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter03.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter04.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter04.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter05.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter05.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter06.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/TryEnter06.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/Monitor/project.json [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/project.json [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread01.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread01.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread02.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread02.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread03.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread03.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread04.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread04.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread05.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread05.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread06.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread06.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread07.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread07.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread08.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread08.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread09.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread09.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread10.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread10.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread11.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread11.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread12.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread12.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread13.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread13.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread14.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread14.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread15.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread15.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread16.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread16.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread17.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread17.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread18.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread18.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread19.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread19.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread20.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread20.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread21.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread21.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread22.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread22.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread23.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread23.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread24.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread24.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread25.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread25.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread26.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread26.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread27.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread27.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread28.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread28.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread29.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread29.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread30.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/thread30.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/project.json [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread01.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread01.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread02.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread02.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread03.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread03.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread04.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread04.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread05.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread05.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread06.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread06.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread07.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread07.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread08.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread08.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread09.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread09.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread10.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread10.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread11.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread11.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread12.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread12.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread13.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread13.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread14.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread14.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread15.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread15.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread16.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread16.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread17.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread17.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread18.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread18.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread19.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread19.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread20.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread20.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread21.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread21.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread22.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread22.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread23.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread23.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread24.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread24.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread25.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread25.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread26.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread26.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread27.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread27.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread28.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread28.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread29.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread29.csproj [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread30.cs [new file with mode: 0644]
tests/src/baseservices/threading/generics/WaitCallback/thread30.csproj [new file with mode: 0644]

diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.cs b/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.cs
new file mode 100644 (file)
index 0000000..0f96e70
--- /dev/null
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+// using System.Configuration;
+using System.Runtime.InteropServices;
+
+namespace StackCommitTest
+{
+    class DefaultStackCommit
+    {
+        static int Main(string[] args)
+        {
+            int result = 1;
+            bool commitEnabled = false;
+
+            if (Utility.RunTest(commitEnabled))
+            {
+                result = 100;
+            }
+
+            Console.WriteLine(result == 100 ? "Success!" : "FAILED!");
+            return result;
+        }
+    }
+}
diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.csproj b/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.csproj
new file mode 100644 (file)
index 0000000..5966cfb
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{c485e164-f82c-4a4f-a02e-bc711827e5be}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="DefaultStackCommit.cs" />
+    <Compile Include="StackCommitCommon.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/DisablePreCommit.exe.config b/tests/src/baseservices/threading/commitstackonlyasneeded/DisablePreCommit.exe.config
new file mode 100644 (file)
index 0000000..eaa1bdc
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <runtime>
+    <disableCommitThreadStack enabled="1" />
+  </runtime>
+  <appSettings>
+    <add key="expectStackCommit" value="false"/>
+  </appSettings>
+</configuration>
diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/EnablePreCommit.exe.config b/tests/src/baseservices/threading/commitstackonlyasneeded/EnablePreCommit.exe.config
new file mode 100644 (file)
index 0000000..cc68420
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <runtime>
+    <disableCommitThreadStack enabled="0" />
+  </runtime>
+  <appSettings>
+    <add key="expectStackCommit" value="true"/>
+  </appSettings>
+</configuration>
diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs b/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs
new file mode 100644 (file)
index 0000000..59dd9f2
--- /dev/null
@@ -0,0 +1,241 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.Threading;
+//using System.Configuration;
+
+namespace StackCommitTest
+{
+    public unsafe class WinApi
+    {
+        [DllImport("kernel32.dll")]
+        public static extern void GetSystemInfo([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_INFO lpSystemInfo);
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct SYSTEM_INFO
+        {
+            internal PROCESSOR_INFO_UNION uProcessorInfo;
+            public uint dwPageSize;
+            public IntPtr lpMinimumApplicationAddress;
+            public IntPtr lpMaximumApplicationAddress;
+            public IntPtr dwActiveProcessorMask;
+            public uint dwNumberOfProcessors;
+            public uint dwProcessorType;
+            public uint dwAllocationGranularity;
+            public ushort dwProcessorLevel;
+            public ushort dwProcessorRevision;
+        }
+
+        [StructLayout(LayoutKind.Explicit)]
+        public struct PROCESSOR_INFO_UNION
+        {
+            [FieldOffset(0)]
+            internal uint dwOemId;
+            [FieldOffset(0)]
+            internal ushort wProcessorArchitecture;
+            [FieldOffset(2)]
+            internal ushort wReserved;
+        }
+
+        [DllImport("kernel32")]
+        public static extern IntPtr VirtualQuery(void* address, ref MEMORY_BASIC_INFORMATION buffer, IntPtr length);
+
+        public struct MEMORY_BASIC_INFORMATION
+        {
+            public byte* BaseAddress;
+            public byte* AllocationBase;
+            public int AllocationProtect;
+            public IntPtr RegionSize;
+            public MemState State;
+            public int Protect;
+            public int Type;
+        }
+
+        [Flags]
+        public enum MemState
+        {
+            MEM_COMMIT = 0x1000,
+            MEM_RESERVE = 0x2000,
+            MEM_FREE = 0x10000,
+        }
+
+
+        public const int PAGE_GUARD = 0x100;
+
+    }
+
+    unsafe public static class Utility
+    {
+        public static Int64 PageSize { get; private set; }
+
+        static Utility()
+        {
+            WinApi.SYSTEM_INFO sysInfo = new WinApi.SYSTEM_INFO();
+
+            WinApi.GetSystemInfo(ref sysInfo);
+
+            PageSize = (Int64)sysInfo.dwPageSize;
+        }
+
+        public static void GetStackExtents(out byte* stackBase, out long stackSize)
+        {
+            WinApi.MEMORY_BASIC_INFORMATION info = new WinApi.MEMORY_BASIC_INFORMATION();
+            WinApi.VirtualQuery(&info, ref info, new IntPtr(sizeof(WinApi.MEMORY_BASIC_INFORMATION)));
+            stackBase = info.AllocationBase;
+            stackSize = (info.BaseAddress - info.AllocationBase) + info.RegionSize.ToInt64();
+        }
+
+        public static List<WinApi.MEMORY_BASIC_INFORMATION> GetRegionsOfStack()
+        {
+            byte* stackBase;
+            long stackSize;
+            GetStackExtents(out stackBase, out stackSize);
+
+            List<WinApi.MEMORY_BASIC_INFORMATION> result = new List<WinApi.MEMORY_BASIC_INFORMATION>();
+
+            byte* current = stackBase;
+            while (current < stackBase + stackSize)
+            {
+                WinApi.MEMORY_BASIC_INFORMATION info = new WinApi.MEMORY_BASIC_INFORMATION();
+                WinApi.VirtualQuery(current, ref info, new IntPtr(sizeof(WinApi.MEMORY_BASIC_INFORMATION)));
+                result.Add(info);
+                current = info.BaseAddress + info.RegionSize.ToInt64();
+            }
+
+            result.Reverse();
+            return result;
+        }
+
+
+        public static bool ValidateStack(string threadName, bool shouldBePreCommitted, Int32 expectedStackSize)
+        {
+            bool result = true;
+
+            byte* stackBase;
+            long stackSize;
+            GetStackExtents(out stackBase, out stackSize);
+
+            Console.WriteLine("{2} -- Base: {0:x}, Size: {1}kb", new IntPtr(stackBase).ToInt64(), stackSize / 1024, threadName);
+
+            //
+            // Start at the highest addresses, which should be committed (because that's where we're currently running).
+            // The next region should be committed, but marked as a guard page.
+            // After that, we'll either find committed pages, or reserved pages, depending on whether the runtime
+            // is pre-committing stacks.
+            //
+            bool foundGuardRegion = false;
+
+            foreach (var info in GetRegionsOfStack())
+            {
+                string regionType = string.Empty;
+
+                if (!foundGuardRegion)
+                {
+                    if ((info.Protect & WinApi.PAGE_GUARD) != 0)
+                    {
+                        foundGuardRegion = true;
+                        regionType = "guard region";
+                    }
+                    else
+                    {
+                        regionType = "active region";
+                    }
+                }
+                else
+                {
+                    if (shouldBePreCommitted)
+                    {
+                        if (!info.State.HasFlag(WinApi.MemState.MEM_COMMIT))
+                        {
+                            // If we pre-commit the stack, the last 1 or 2 pages are left "reserved" (they are the "hard guard region")
+                            // ??? How to decide whether it is 1 or 2 pages?
+                            if ((info.BaseAddress != stackBase || info.RegionSize.ToInt64() > PageSize))
+                            {
+                                result = false;
+                                regionType = "<---- should be pre-committed";
+                            }
+                        }
+                    }
+                    else
+                    {
+                        if (info.State.HasFlag(WinApi.MemState.MEM_COMMIT))
+                        {
+                            result = false;
+                            regionType = "<---- should not be pre-committed";
+                        }
+                    }
+                }
+
+                Console.WriteLine(
+                    "{0:x8}-{1:x8} {2,5:g}kb {3,-11:g} {4}",
+                    new IntPtr(info.BaseAddress).ToInt64(),
+                    new IntPtr(info.BaseAddress + info.RegionSize.ToInt64()).ToInt64(),
+                    info.RegionSize.ToInt64() / 1024,
+                    info.State,
+                    regionType);
+            }
+
+            if (!foundGuardRegion)
+            {
+                result = false;
+
+                Console.WriteLine("Did not find GuardRegion for the whole stack");
+            }
+
+            if (expectedStackSize != -1 && stackSize != expectedStackSize)
+            {
+                result = false;
+
+                Console.WriteLine("Stack size is not as expected: actual -- {0}, expected -- {1}", stackSize, expectedStackSize);
+            }
+
+            Console.WriteLine();
+            return result;
+        }
+
+        static private bool RunTestItem(string threadName, bool shouldBePreCommitted, Int32 expectedThreadSize, Action<Action> runOnThread)
+        {
+            bool result = false;
+            ManualResetEventSlim mre = new ManualResetEventSlim();
+
+            runOnThread(() =>
+            {
+                result = Utility.ValidateStack(threadName, shouldBePreCommitted, expectedThreadSize);
+                mre.Set();
+            });
+
+            mre.Wait();
+            return result;
+        }
+
+        static public bool RunTest(bool shouldBePreCommitted)
+        {
+            if (RunTestItem("Main", shouldBePreCommitted, -1, action => action()) &
+                RunTestItem("ThreadPool", shouldBePreCommitted, -1, action => ThreadPool.QueueUserWorkItem(state => action())) &
+                RunTestItem("new Thread()", shouldBePreCommitted, -1, action => new Thread(() => action()).Start()) &
+                //RunTestItem("new Thread(512kb)", true, 512 * 1024, action => new Thread(() => action(), 512 * 1024).Start()) &
+                RunTestItem("Finalizer", shouldBePreCommitted, -1, action => Finalizer.Run(action)))
+            {
+                return true;
+            }
+
+            return false;
+        }
+    }
+
+    public class Finalizer
+    {
+        Action m_action;
+        private Finalizer(Action action) { m_action = action; }
+        ~Finalizer() { m_action(); }
+
+        public static void Run(Action action)
+        {
+            new Finalizer(action);
+            GC.Collect();
+            GC.WaitForPendingFinalizers();
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/project.json b/tests/src/baseservices/threading/commitstackonlyasneeded/project.json
new file mode 100644 (file)
index 0000000..c14efc6
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.cs
new file mode 100644 (file)
index 0000000..2d9e4b6
--- /dev/null
@@ -0,0 +1,147 @@
+using System;
+using System.Threading;
+
+public class mytest {
+       public static int Main(String [] args) {
+               int               rValue = 100;
+               AutoResetEvent    are  = null;
+               
+               Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions");
+               Console.WriteLine( );
+
+
+//             try {
+// #pragma warning disable 618
+//                     are.Handle = new IntPtr(1);
+// #pragma warning restore 618
+//                     rValue = 1;
+//             }
+//             catch (NullReferenceException) {
+//                     Console.WriteLine("Caught NullReferenceException   (are.Handle(new IntPtr(1)))");
+//             }
+//             try {
+// #pragma warning disable 618
+//                     IntPtr iptr = are.Handle;
+// #pragma warning restore 618
+//                     rValue = 2;
+//             }
+//             catch (NullReferenceException) {
+//                     Console.WriteLine("Caught NullReferenceException   (IntPtr iptr = are.Handle)");
+//             }
+       
+               // try {
+               //      are.Close();
+               //      rValue = 3;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (are.Close())");
+               // }
+               
+               try {
+                       are.Equals(new ManualResetEvent(true));
+                       rValue = 4;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (are.Equals(new ManualResetEvent()))");
+               }
+
+               try {
+                       are.GetHashCode();
+                       rValue = 5;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (are.GetHasCode())");
+               }
+
+               // try {
+               //      are.GetLifetimeService();
+               //      rValue = 6;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (are.GetLifetimeService())");
+               // }            
+
+               try {
+                       are.GetType();
+                       rValue = 7;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (are.GetType())");
+               }
+
+               // try {
+               //      are.InitializeLifetimeService();
+               //      rValue = 8;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (are.InitializeLifeTimeService())");
+               // }
+       
+               try {
+                       are.Reset();
+                       rValue = 9;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (are.Reset())");
+               }
+
+               try {
+                       are.Set();
+                       rValue = 10;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (are.Set())");
+               }
+
+               try {
+                       are.ToString();
+                       rValue = 11;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (are.ToString())");
+               }
+
+               try {
+                       are.WaitOne();
+                       rValue = 12;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (are.WaitOne())");
+               }
+
+               try {
+                       are.WaitOne(1000);//,true);
+                       rValue = 13;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (are.WaitOne(int,bool))");
+               }
+
+               // try {
+               //      are.WaitOne(1000);//,false);
+               //      rValue = 14;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (are.WaitOne(int,bool))");
+               // }
+
+               try {
+                       are.WaitOne(new TimeSpan(1000));//,true);
+                       rValue = 15;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (are.WaitOne(TimeSpan,bool))");
+               }
+
+               // try {
+               //      are.WaitOne(new TimeSpan(1000));//,false);
+               //      rValue = 16;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (are.WaitOne(TimeSpan,bool))");
+               // }            
+
+               Console.WriteLine("Return Code == {0}",rValue);
+               return rValue;
+       }
+}
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.csproj
new file mode 100644 (file)
index 0000000..65323f9
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="CS_ARENullRefEx.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.cs
new file mode 100644 (file)
index 0000000..443cd2a
--- /dev/null
@@ -0,0 +1,147 @@
+using System;
+using System.Threading;
+
+public class mytest {
+       public static int Main(String [] args) {
+               int               rValue = 100;
+               ManualResetEvent  mre  = null;
+               
+               Console.WriteLine("Test ManualResetEvent for expected NullRef Exceptions");
+               Console.WriteLine( );
+
+
+//             try {
+// #pragma warning disable 618
+//                     mre.Handle = new IntPtr(1);
+// #pragma warning restore 618
+//                     rValue = 1;
+//             }
+//             catch (NullReferenceException) {
+//                     Console.WriteLine("Caught NullReferenceException   (mre.Handle(new IntPtr(1)))");
+//             }
+//             try {
+// #pragma warning disable 618
+//                     IntPtr iptr = mre.Handle;
+// #pragma warning restore 618
+//                     rValue = 2;
+//             }
+//             catch (NullReferenceException) {
+//                     Console.WriteLine("Caught NullReferenceException   (IntPtr iptr = mre.Handle)");
+//             }
+       
+               // try {
+               //      mre.Close();
+               //      rValue = 3;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mre.Close())");
+               // }
+               
+               try {
+                       mre.Equals(new ManualResetEvent(true));
+                       rValue = 4;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mre.Equals(new ManualResetEvent()))");
+               }
+
+               try {
+                       mre.GetHashCode();
+                       rValue = 5;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mre.GetHasCode())");
+               }
+
+               // try {
+               //      mre.GetLifetimeService();
+               //      rValue = 6;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mre.GetLifetimeService())");
+               // }            
+
+               try {
+                       mre.GetType();
+                       rValue = 7;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mre.GetType())");
+               }
+
+               // try {
+               //      mre.InitializeLifetimeService();
+               //      rValue = 8;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mre.InitializeLifeTimeService())");
+               // }
+       
+               try {
+                       mre.Reset();
+                       rValue = 9;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mre.Reset())");
+               }
+
+               try {
+                       mre.Set();
+                       rValue = 10;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mre.Set())");
+               }
+
+               try {
+                       mre.ToString();
+                       rValue = 11;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mre.ToString())");
+               }
+
+               try {
+                       mre.WaitOne();
+                       rValue = 12;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mre.WaitOne())");
+               }
+
+               try {
+                       mre.WaitOne(1000);//,true);
+                       rValue = 13;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mre.WaitOne(int)");
+               }
+
+               // try {
+               //      mre.WaitOne(1000);//,false);
+               //      rValue = 14;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mre.WaitOne(int,bool))");
+               // }
+
+               try {
+                       mre.WaitOne(new TimeSpan(1000));//,true);
+                       rValue = 15;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mre.WaitOne(TimeSpan)");
+               }
+
+               // try {
+               //      mre.WaitOne(new TimeSpan(1000));//,false);
+               //      rValue = 16;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mre.WaitOne(TimeSpan,bool))");
+               // }            
+
+               Console.WriteLine("Return Code == {0}",rValue);
+               return rValue;
+       }
+}
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.csproj
new file mode 100644 (file)
index 0000000..797ad91
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="CS_MRENullRefEx.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.cs
new file mode 100644 (file)
index 0000000..dfa0558
--- /dev/null
@@ -0,0 +1,139 @@
+using System;
+using System.Threading;
+
+public class mytest {
+       public static int Main(String [] args) {
+               int    rValue = 100;
+               Mutex  mut    = null;
+               
+               Console.WriteLine("Test Mutex for expected NullRef Exceptions");
+               Console.WriteLine( );
+
+
+//             try {
+// #pragma warning disable 618
+//                     mut.Handle = new IntPtr(1);
+// #pragma warning restore 618
+//                     rValue = 1;
+//             }
+//             catch (NullReferenceException) {
+//                     Console.WriteLine("Caught NullReferenceException   (mut.Handle(new IntPtr(1)))");
+//             }
+//             try {
+// #pragma warning disable 618
+//                     IntPtr iptr = mut.Handle;
+// #pragma warning restore 618
+//                     rValue = 2;
+//             }
+//             catch (NullReferenceException) {
+//                     Console.WriteLine("Caught NullReferenceException   (IntPtr iptr = mut.Handle)");
+//             }
+       
+               // try {
+               //      mut.Close();
+               //      rValue = 3;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mut.Close())");
+               // }
+               
+               try {
+                       mut.Equals(new ManualResetEvent(true));
+                       rValue = 4;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mut.Equals(new ManualResetEvent()))");
+               }
+
+               try {
+                       mut.GetHashCode();
+                       rValue = 5;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mut.GetHasCode())");
+               }
+
+               // try {
+               //      mut.GetLifetimeService();
+               //      rValue = 6;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mut.GetLifetimeService())");
+               // }            
+
+               try {
+                       mut.GetType();
+                       rValue = 7;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mut.GetType())");
+               }
+
+               // try {
+               //      mut.InitializeLifetimeService();
+               //      rValue = 8;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mut.InitializeLifeTimeService())");
+               // }
+       
+               try {
+                       mut.ReleaseMutex();
+                       rValue = 9;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mut.ReleaseMutex())");
+               }
+
+               try {
+                       mut.ToString();
+                       rValue = 11;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mut.ToString())");
+               }
+
+               try {
+                       mut.WaitOne();
+                       rValue = 12;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mut.WaitOne())");
+               }
+
+               try {
+                       mut.WaitOne(1000);//,true);
+                       rValue = 13;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mut.WaitOne(int)");
+               }
+
+               // try {
+               //      mut.WaitOne(1000,false);
+               //      rValue = 14;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mut.WaitOne(int,bool))");
+               // }
+
+               try {
+                       mut.WaitOne(new TimeSpan(1000));//,true);
+                       rValue = 15;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (mut.WaitOne(TimeSpan))");
+               }
+
+               // try {
+               //      mut.WaitOne(new TimeSpan(1000),false);
+               //      rValue = 16;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (mut.WaitOne(TimeSpan,bool))");
+               // }            
+
+               Console.WriteLine("Return Code == {0}",rValue);
+               return rValue;
+       }
+}
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.csproj
new file mode 100644 (file)
index 0000000..4a9f791
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="CS_MutexNullRefEx.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.cs
new file mode 100644 (file)
index 0000000..5761876
--- /dev/null
@@ -0,0 +1,73 @@
+using System;
+using System.Threading;
+
+public class mytest {
+       public static int Main(String [] args) {
+               int                   rValue = 100;
+               RegisteredWaitHandle  rwh    = null;
+               
+               Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions");
+               Console.WriteLine( );
+
+               
+               try {
+                       rwh.Equals(new ManualResetEvent(true));
+                       rValue = 4;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (rwh.Equals(new ManualResetEvent()))");
+               }
+
+               try {
+                       rwh.GetHashCode();
+                       rValue = 5;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (rwh.GetHasCode())");
+               }
+
+               // try {
+               //      rwh.GetLifetimeService();
+               //      rValue = 6;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (rwh.GetLifetimeService())");
+               // }            
+
+               try {
+                       rwh.GetType();
+                       rValue = 7;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (rwh.GetType())");
+               }
+
+               // try {
+               //      rwh.InitializeLifetimeService();
+               //      rValue = 8;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (rwh.InitializeLifeTimeService())");
+               // }
+
+               try {
+                       rwh.ToString();
+                       rValue = 11;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (rwh.ToString())");
+               }
+
+               try {
+                       rwh.Unregister(new AutoResetEvent(true));
+                       rValue = 12;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (rwh.Unregister())");
+               }
+               
+
+               Console.WriteLine("Return Code == {0}",rValue);
+               return rValue;
+       }
+}
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.csproj
new file mode 100644 (file)
index 0000000..ff722ba
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="CS_RWHNullRefEx.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.cs
new file mode 100644 (file)
index 0000000..0ec905e
--- /dev/null
@@ -0,0 +1,122 @@
+using System;
+using System.Threading;
+// using System.Runtime.Remoting;
+using System.Runtime.Serialization;
+
+public class mytest {
+       public static int Main(String [] args) {
+               int                           rValue = 100;
+               SynchronizationLockException  sle    = null;
+               
+               Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions");
+               Console.WriteLine( );
+
+               try {
+                       sle.HelpLink = "Hello";
+                       rValue = 1;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.HelpLink = Hello)");
+               }
+
+               try {
+                       String s = sle.HelpLink;
+                       rValue = 2;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (string s = sle.HelpLink)");
+               }
+
+               try {
+                       Exception e = sle.InnerException;
+                       rValue = 3;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.InnerException)");
+               }
+
+               try {
+                       String s = sle.Message;
+                       rValue = 4;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.Message)");
+               }
+
+               try {
+                       String s = sle.Source;
+                       rValue = 5;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.Source)");
+               }
+
+               try {
+                       String s = sle.StackTrace;
+                       rValue = 6;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.StackTrace)");
+               }
+               
+               // try {
+               //      sle.TargetSite.ToString();
+               //      rValue = 7;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (sle.TargetSite))");
+               // }
+               
+               try {
+                       sle.Equals(new Exception("Hello"));
+                       rValue = 8;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.Equals(new Exception()))");
+               }
+
+               try {
+                       sle.GetBaseException();
+                       rValue = 9;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.GetBaseException())");
+               }
+
+               try {
+                       sle.GetHashCode();
+                       rValue = 10;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.GetHasCode())");
+               }
+
+               // try {
+               //      sle.GetObjectData(new SerializationInfo(1.GetType(),new FormatterConverter()),new StreamingContext(StreamingContextStates.All));
+               //      rValue = 11;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (sle.ObjectData(SerializationInfo,StreamingContext))");
+               // }            
+
+               try {
+                       sle.GetType();
+                       rValue = 12;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.GetType())");
+               }
+
+               try {
+                       sle.ToString();
+                       rValue = 13;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (sle.ToString())");
+               }
+               
+
+               Console.WriteLine("Return Code == {0}",rValue);
+               return rValue;
+       }
+}
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.csproj
new file mode 100644 (file)
index 0000000..96fb110
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="CS_SLENullRefEx.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.cs
new file mode 100644 (file)
index 0000000..d8a21fa
--- /dev/null
@@ -0,0 +1,121 @@
+using System;
+using System.Threading;
+using System.Runtime.Serialization;
+
+public class mytest {
+       public static int Main(String [] args) {
+               int                      rValue = 100;
+               ThreadStateException     ta     = null;
+               
+               Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions");
+               Console.WriteLine( );
+
+               try {
+                       ta.HelpLink = "Hello";
+                       rValue = 1;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.HelpLink = Hello)");
+               }
+
+               try {
+                       String s = ta.HelpLink;
+                       rValue = 2;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (string s = ta.HelpLink)");
+               }
+
+               try {
+                       Exception e = ta.InnerException;
+                       rValue = 3;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.InnerException)");
+               }
+
+               try {
+                       String s = ta.Message;
+                       rValue = 4;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.Message)");
+               }
+
+               try {
+                       String s = ta.Source;
+                       rValue = 5;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.Source)");
+               }
+
+               try {
+                       String s = ta.StackTrace;
+                       rValue = 6;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.StackTrace)");
+               }
+               
+               // try {
+               //      ta.TargetSite.ToString();
+               //      rValue = 7;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (ta.TargetSite))");
+               // }
+               
+               try {
+                       ta.Equals(new Exception("Hello"));
+                       rValue = 8;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.Equals(new Exception()))");
+               }
+
+               try {
+                       ta.GetBaseException();
+                       rValue = 9;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.GetBaseException())");
+               }
+
+               try {
+                       ta.GetHashCode();
+                       rValue = 10;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.GetHasCode())");
+               }
+
+               // try {
+               //      ta.GetObjectData(new SerializationInfo(1.GetType(),new FormatterConverter()),new StreamingContext(StreamingContextStates.All));
+               //      rValue = 11;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (ta.ObjectData(SerializationInfo,StreamingContext))");
+               // }            
+
+               try {
+                       ta.GetType();
+                       rValue = 12;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.GetType())");
+               }
+
+               try {
+                       ta.ToString();
+                       rValue = 13;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (ta.ToString())");
+               }
+               
+
+               Console.WriteLine("Return Code == {0}",rValue);
+               return rValue;
+       }
+}
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.csproj
new file mode 100644 (file)
index 0000000..b4efdd6
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="CS_TSNullRefEx.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.cs
new file mode 100644 (file)
index 0000000..80845a1
--- /dev/null
@@ -0,0 +1,111 @@
+using System;
+using System.Threading;
+
+public class mytest {
+       public static int Main(String [] args) {
+               
+               int   rValue = 100;
+               Timer time   = null;
+
+               Console.WriteLine("Test that timer fields return correct null ref");
+
+               try {
+                       time.Change(5,10);
+                       rValue = 1;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (time.Change(5,10)");
+               }
+
+               try {
+                       time.Change(5,10);
+                       rValue = 2;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (time.Change((long)5,(long)10)");
+               }
+
+               try {
+                       time.Change(new TimeSpan(500),new TimeSpan(100));
+                       rValue = 3;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (time.Change(new TimeSpan(500),new TimeSpan(100))");
+               }
+
+               try {
+                       time.Change(500,100);
+                       rValue = 4;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (time.Change((uint)500,(uint)100)");
+               }
+
+               try {
+                       time.Dispose();
+                       rValue = 5;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (time.Dispose( ))");
+               }
+
+               // try {
+               //      time.Dispose(new AutoResetEvent(true));
+               //      rValue = 6;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (time.Dispose(new WaitHandle( )))");
+               // }
+
+               try {
+                       time.Equals(new AutoResetEvent(true));
+                       rValue = 7;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (time.Equals(new WaitHandle( )))");
+               }
+
+               try {
+                       time.GetHashCode();
+                       rValue = 8;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (time.GetHashCode())");
+               }
+
+               // try {
+               //      time.GetLifetimeService();
+               //      rValue = 9;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (time.GetLifetimeService())");
+               // }
+
+               try {
+                       time.GetType();
+                       rValue = 10;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (time.GetType())");
+               }
+
+               // try {
+               //      time.InitializeLifetimeService();
+               //      rValue = 11;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (time.InitializeLifetimeService())");
+               // }
+
+               try {
+                       time.ToString();
+                       rValue = 12;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (time.ToString())");
+               }
+
+               Console.WriteLine("Return Code == {0}",rValue);
+               return rValue;
+       }
+}
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.csproj
new file mode 100644 (file)
index 0000000..8539d89
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="CS_TimerNullRefEx.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.cs
new file mode 100644 (file)
index 0000000..eb5c589
--- /dev/null
@@ -0,0 +1,131 @@
+using System;
+using System.Threading;
+
+public class mytest {
+       public static int Main(String [] args) {
+               int         rValue = 100;
+               WaitHandle  wh     = null;
+               
+               Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions");
+               Console.WriteLine( );
+
+
+//             try {
+// #pragma warning disable 618
+//                     wh.Handle = new IntPtr(1);
+// #pragma warning restore 618
+//                     rValue = 1;
+//             }
+//             catch (NullReferenceException) {
+//                     Console.WriteLine("Caught NullReferenceException   (wh.Handle(new IntPtr(1)))");
+//             }
+//             try {
+// #pragma warning disable 618
+//                     IntPtr iptr = wh.Handle;
+// #pragma warning restore 618
+//                     rValue = 2;
+//             }
+//             catch (NullReferenceException) {
+//                     Console.WriteLine("Caught NullReferenceException   (IntPtr iptr = wh.Handle)");
+//             }
+       
+               // try {
+               //      wh.Close();
+               //      rValue = 3;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (wh.Close())");
+               // }
+               
+               try {
+                       wh.Equals(new ManualResetEvent(true));
+                       rValue = 4;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (wh.Equals(new ManualResetEvent()))");
+               }
+
+               try {
+                       wh.GetHashCode();
+                       rValue = 5;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (wh.GetHasCode())");
+               }
+
+               // try {
+               //      wh.GetLifetimeService();
+               //      rValue = 6;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (wh.GetLifetimeService())");
+               // }            
+
+               try {
+                       wh.GetType();
+                       rValue = 7;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (wh.GetType())");
+               }
+
+               // try {
+               //      wh.InitializeLifetimeService();
+               //      rValue = 8;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (wh.InitializeLifeTimeService())");
+               // }
+
+               try {
+                       wh.ToString();
+                       rValue = 11;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (wh.ToString())");
+               }
+
+               try {
+                       wh.WaitOne();
+                       rValue = 12;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (wh.WaitOne())");
+               }
+
+               try {
+                       wh.WaitOne(1000);//,true);
+                       rValue = 13;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (wh.WaitOne(int))");
+               }
+
+               // try {
+               //      wh.WaitOne(1000,false);
+               //      rValue = 14;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (wh.WaitOne(int,bool))");
+               // }
+
+               try {
+                       wh.WaitOne(new TimeSpan(1000));//,true);
+                       rValue = 15;
+               }
+               catch (NullReferenceException) {
+                       Console.WriteLine("Caught NullReferenceException   (wh.WaitOne(TimeSpan,bool))");
+               }
+
+               // try {
+               //      wh.WaitOne(new TimeSpan(1000),false);
+               //      rValue = 16;
+               // }
+               // catch (NullReferenceException) {
+               //      Console.WriteLine("Caught NullReferenceException   (wh.WaitOne(TimeSpan,bool))");
+               // }            
+
+               Console.WriteLine("Return Code == {0}",rValue);
+               return rValue;
+       }
+}
diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.csproj
new file mode 100644 (file)
index 0000000..ea0a01a
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="CS_WHNullRefEx.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/coverage/Nullref/project.json b/tests/src/baseservices/threading/coverage/Nullref/project.json
new file mode 100644 (file)
index 0000000..864cd20
--- /dev/null
@@ -0,0 +1,35 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.Timer": "4.0.0-rc3-23823",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.cs b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.cs
new file mode 100644 (file)
index 0000000..b2b4aed
--- /dev/null
@@ -0,0 +1,65 @@
+using System;
+using System.Threading;
+using System.Diagnostics;
+
+public class ARETestClass
+{
+
+       public static int Main()
+       {
+               ARETestClass testAutoReset = new ARETestClass();
+               int ret = testAutoReset.Run();
+               Console.WriteLine(ret == 100 ? "Test Passed":"Test Failed");
+               return ret;
+       }
+
+       public int Run()
+       {
+               Stopwatch sw = new Stopwatch();         
+               AutoResetEvent are = new AutoResetEvent(false);
+               sw.Start();
+               bool ret = are.WaitOne(1000);//,false);
+               sw.Stop();
+               //We should never get signaled
+               if(ret)
+               {
+                       Console.WriteLine("AutoResetEvent should never be signalled.");
+                       return -1;
+               }
+
+               if(sw.ElapsedMilliseconds < 900)
+               {
+                       Console.WriteLine("It should take at least 900 milliseconds to call bool ret = are.WaitOne(1000,false);.");
+                       Console.WriteLine("sw.ElapsedMilliseconds = " + sw.ElapsedMilliseconds);                        
+                       return -2;
+               }
+               
+               are.Set();
+               if(!are.WaitOne(0))//,false))
+               {
+                       Console.WriteLine("Signalled event should always return true on call to !are.WaitOne(0,false).");
+                       return -3;
+               }
+               
+               sw.Reset();             
+               sw.Start();
+               ret = are.WaitOne(1000);//,false);
+               sw.Stop();
+               //We should never get signaled
+               if(ret)
+               {
+                       Console.WriteLine("AutoResetEvent should never be signalled after is is AutoReset.");
+                       return -4;
+               }
+
+               if(sw.ElapsedMilliseconds < 900)
+               {
+                       Console.WriteLine("It should take at least 900 milliseconds to call bool ret = are.WaitOne(1000,false);.");
+                       Console.WriteLine("sw.ElapsedMilliseconds = " + sw.ElapsedMilliseconds);                        
+                       return -5;
+               }
+               
+               return 100;
+               
+       }
+}
diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.csproj b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.csproj
new file mode 100644 (file)
index 0000000..b67abf1
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{1de36f31-ddef-43ff-a8e8-e09f11711c13}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ConstructFalse.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.cs b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.cs
new file mode 100644 (file)
index 0000000..9fedcc4
--- /dev/null
@@ -0,0 +1,47 @@
+using System;
+using System.Threading;
+using System.Diagnostics;
+
+public class ARETestClass
+{
+
+       public static int Main()
+       {
+               ARETestClass testAutoReset = new ARETestClass();
+
+               int ret = testAutoReset.Run();
+               Console.WriteLine(ret == 100 ? "Test Passed":"Test Failed");
+               return ret;
+       }
+
+       public int Run()
+       {
+               AutoResetEvent are = new AutoResetEvent(true);
+               Stopwatch sw = new Stopwatch();         
+               
+               if(!are.WaitOne(0))//,false))
+{
+                       Console.WriteLine("Signalled event should always return true on call to !are.WaitOne(0,false).");
+                       return -3;
+               }
+               
+               sw.Start();
+               bool ret = are.WaitOne(1000);//,false);
+               sw.Stop();
+               //We should never get signaled
+               if(ret)
+               {
+                       Console.WriteLine("AutoResetEvent should never be signalled.");
+                       return -1;
+               }
+
+               if(sw.ElapsedMilliseconds < 900)
+               {
+                       Console.WriteLine("It should take at least 900 milliseconds to call bool ret = are.WaitOne(1000,false);.");
+                       Console.WriteLine("sw.ElapsedMilliseconds = " + sw.ElapsedMilliseconds);                        
+                       return -2;
+               }
+               return 100;
+               
+       }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.csproj b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.csproj
new file mode 100644 (file)
index 0000000..715b25e
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{1de36f31-ddef-43ff-a8e8-e09f11711c13}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ConstructTrue.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/project.json b/tests/src/baseservices/threading/events/AutoResetEvent/project.json
new file mode 100644 (file)
index 0000000..c14efc6
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.cs b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.cs
new file mode 100644 (file)
index 0000000..1048797
--- /dev/null
@@ -0,0 +1,42 @@
+using System;
+using System.Threading;
+
+class AutoResetCtor
+{
+    EventWaitHandle ewh;
+
+    public static int Main()
+    {
+        AutoResetCtor arc = new AutoResetCtor();
+        return arc.Run();
+    }
+
+    private int Run()
+    {
+        // Testing the initialState = true for an AutoResetEvent
+        int iRet = -1;
+        ewh = (EventWaitHandle)new AutoResetEvent(true);
+
+        Thread t = new Thread(new ThreadStart(ThreadWorker));
+        t.Start();
+        t.Join();
+
+        // when doing another wait, it should not return until set.
+        Console.WriteLine("Main: Waiting...");
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            Console.WriteLine("WaitOne didn't reset!");
+        else
+            iRet = 100;
+
+        Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+        return iRet;
+    }
+    
+    private void ThreadWorker()
+    {
+        Console.WriteLine("TW: Waiting...");
+        // This should return immediately
+        ewh.WaitOne();
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.csproj
new file mode 100644 (file)
index 0000000..a76597b
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="AutoResetCast1.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.cs b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.cs
new file mode 100644 (file)
index 0000000..28f5eca
--- /dev/null
@@ -0,0 +1,47 @@
+using System;
+using System.Threading;
+
+class AutoResetCtor
+{
+    EventWaitHandle ewh;
+    int iRet = -1;
+
+    public static int Main()
+    {
+        AutoResetCtor arc = new AutoResetCtor();
+        return arc.Run();
+    }
+
+    private int Run()
+    {
+        // Testing the initialState = false for an AutoResetEvent
+        ewh = (EventWaitHandle)new AutoResetEvent(false);
+
+        Thread t = new Thread(new ThreadStart(ThreadWorker));
+        t.Start();
+        t.Join();
+
+        ewh.Set();
+        // when doing another wait, it should return immediately
+        Console.WriteLine("Main: Waiting...");
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            iRet += 50;
+        else
+            Console.WriteLine("WaitOne() timed out");
+
+        Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+        return iRet;
+    }
+    
+    private void ThreadWorker()
+    {
+        Console.WriteLine("TW: Waiting...");
+        // This should NOT return immediately
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            Console.WriteLine("WaitOne returned successful");
+        else
+            iRet = 50;
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.csproj
new file mode 100644 (file)
index 0000000..8655509
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="AutoResetCast2.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.cs b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.cs
new file mode 100644 (file)
index 0000000..69d2e44
--- /dev/null
@@ -0,0 +1,42 @@
+using System;
+using System.Threading;
+
+class AutoResetCtor
+{
+    EventWaitHandle ewh;
+
+    public static int Main()
+    {
+        AutoResetCtor arc = new AutoResetCtor();
+        return arc.Run();
+    }
+
+    private int Run()
+    {
+        // Testing the initialState = true for an AutoResetEvent
+        int iRet = -1;
+        ewh = new EventWaitHandle(true, EventResetMode.AutoReset);
+
+        Thread t = new Thread(new ThreadStart(ThreadWorker));
+        t.Start();
+        t.Join();
+
+        // when doing another wait, it should not return until set.
+        Console.WriteLine("Main: Waiting...");
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            Console.WriteLine("WaitOne didn't reset!");
+        else
+            iRet = 100;
+
+        Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+        return iRet;
+    }
+    
+    private void ThreadWorker()
+    {
+        Console.WriteLine("TW: Waiting...");
+        // This should return immediately
+        ewh.WaitOne();
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.csproj
new file mode 100644 (file)
index 0000000..9b62b50
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="AutoResetCtor1.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.cs b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.cs
new file mode 100644 (file)
index 0000000..c3994af
--- /dev/null
@@ -0,0 +1,47 @@
+using System;
+using System.Threading;
+
+class AutoResetCtor
+{
+    EventWaitHandle ewh;
+    int iRet = -1;
+
+    public static int Main()
+    {
+        AutoResetCtor arc = new AutoResetCtor();
+        return arc.Run();
+    }
+
+    private int Run()
+    {
+        // Testing the initialState = false for an AutoResetEvent
+        ewh = new EventWaitHandle(false, EventResetMode.AutoReset);
+
+        Thread t = new Thread(new ThreadStart(ThreadWorker));
+        t.Start();
+        t.Join();
+
+        ewh.Set();
+        // when doing another wait, it should return immediately
+        Console.WriteLine("Main: Waiting...");
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            iRet += 50;
+        else
+            Console.WriteLine("WaitOne() timed out");
+
+        Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+        return iRet;
+    }
+    
+    private void ThreadWorker()
+    {
+        Console.WriteLine("TW: Waiting...");
+        // This should NOT return immediately
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            Console.WriteLine("WaitOne returned successful");
+        else
+            iRet = 50;
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.csproj
new file mode 100644 (file)
index 0000000..9499bac
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="AutoResetCtor2.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/project.json b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/project.json
new file mode 100644 (file)
index 0000000..864cd20
--- /dev/null
@@ -0,0 +1,35 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.Timer": "4.0.0-rc3-23823",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.cs b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.cs
new file mode 100644 (file)
index 0000000..2ad09bb
--- /dev/null
@@ -0,0 +1,44 @@
+using System;
+using System.Threading;
+
+class ManualResetCtor
+{
+    EventWaitHandle ewh;
+
+    public static int Main()
+    {
+        ManualResetCtor mrc = new ManualResetCtor();
+        return mrc.Run();
+    }
+
+    private int Run()
+    {
+        // Testing the initialState = true for a ManualResetEvent
+        int iRet = -1;
+        ewh = (EventWaitHandle)new ManualResetEvent(true);
+
+        Thread t = new Thread(new ThreadStart(ThreadWorker));
+        t.Start();
+        t.Join();
+
+        // This should return immediately
+        ewh.WaitOne();
+        ewh.Reset();
+
+        // when doing another wait, it should not return until set.
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            Console.WriteLine("Event didn't reset!");
+        else
+            iRet = 100;
+
+        Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+        return iRet;
+    }
+    
+    private void ThreadWorker()
+    {
+        // This should return immediately
+        ewh.WaitOne();
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.csproj
new file mode 100644 (file)
index 0000000..73cfcb2
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ManualResetCast1.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.cs b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.cs
new file mode 100644 (file)
index 0000000..dc1af59
--- /dev/null
@@ -0,0 +1,45 @@
+using System;
+using System.Threading;
+
+class ManualResetCtor
+{
+    EventWaitHandle ewh;
+    int iRet = -1;
+
+    public static int Main()
+    {
+        ManualResetCtor mrc = new ManualResetCtor();
+        return mrc.Run();
+    }
+
+    private int Run()
+    {
+        // Testing the initialState = false for a ManualResetEvent
+        ewh = (EventWaitHandle)new ManualResetEvent(false);
+
+        Thread t = new Thread(new ThreadStart(ThreadWorker));
+        t.Start();
+        t.Join();
+
+        ewh.Set();
+        // when doing another wait, it should return immediately
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            iRet += 50;
+        else
+            Console.WriteLine("WaitOne() timed out");
+
+        Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+        return iRet;
+    }
+    
+    private void ThreadWorker()
+    {
+        // This should NOT return immediately
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            Console.WriteLine("WaitOne returned successful");
+        else
+            iRet = 50;
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.csproj
new file mode 100644 (file)
index 0000000..5a26b30
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ManualResetCast2.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.cs b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.cs
new file mode 100644 (file)
index 0000000..6335cef
--- /dev/null
@@ -0,0 +1,44 @@
+using System;
+using System.Threading;
+
+class ManualResetCtor
+{
+    EventWaitHandle ewh;
+
+    public static int Main()
+    {
+        ManualResetCtor mrc = new ManualResetCtor();
+        return mrc.Run();
+    }
+
+    private int Run()
+    {
+        // Testing the initialState = true for a ManualResetEvent
+        int iRet = -1;
+        ewh = new EventWaitHandle(true, EventResetMode.ManualReset);
+
+        Thread t = new Thread(new ThreadStart(ThreadWorker));
+        t.Start();
+        t.Join();
+
+        // This should return immediately
+        ewh.WaitOne();
+        ewh.Reset();
+
+        // when doing another wait, it should not return until set.
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            Console.WriteLine("Event didn't reset!");
+        else
+            iRet = 100;
+
+        Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+        return iRet;
+    }
+    
+    private void ThreadWorker()
+    {
+        // This should return immediately
+        ewh.WaitOne();
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.csproj
new file mode 100644 (file)
index 0000000..62cb647
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ManualResetCtor1.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.cs b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.cs
new file mode 100644 (file)
index 0000000..e19f99d
--- /dev/null
@@ -0,0 +1,45 @@
+using System;
+using System.Threading;
+
+class ManualResetCtor
+{
+    EventWaitHandle ewh;
+    int iRet = -1;
+
+    public static int Main()
+    {
+        ManualResetCtor mrc = new ManualResetCtor();
+        return mrc.Run();
+    }
+
+    private int Run()
+    {
+        // Testing the initialState = false for a ManualResetEvent
+        ewh = new EventWaitHandle(false, EventResetMode.ManualReset);
+
+        Thread t = new Thread(new ThreadStart(ThreadWorker));
+        t.Start();
+        t.Join();
+
+        ewh.Set();
+        // when doing another wait, it should return immediately
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            iRet += 50;
+        else
+            Console.WriteLine("WaitOne() timed out");
+
+        Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+        return iRet;
+    }
+    
+    private void ThreadWorker()
+    {
+        // This should NOT return immediately
+        bool b = ewh.WaitOne(5000);//, false);
+        if(b)
+            Console.WriteLine("WaitOne returned successful");
+        else
+            iRet = 50;
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.csproj
new file mode 100644 (file)
index 0000000..37f40de
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ManualResetCtor2.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/project.json b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/project.json
new file mode 100644 (file)
index 0000000..c14efc6
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/NamedCommon.cs b/tests/src/baseservices/threading/events/EventWaitHandle/NamedCommon.cs
new file mode 100644 (file)
index 0000000..e793b73
--- /dev/null
@@ -0,0 +1,32 @@
+using System;
+using System.Threading;
+
+class Common
+{
+    public static string GenerateUnicodeString(int iNumChars)
+    {
+        Random rand = new Random();
+        string semName = string.Empty;
+        string semNameNum = string.Empty;
+        for (int i = 0; i < iNumChars; i++)
+        {
+            char c = '\\';
+            while (c == '\\')
+            {
+               c = (char)rand.Next(Char.MinValue, Char.MaxValue);
+            }
+            semNameNum += ((int)c).ToString() + ";";
+            semName += c;
+        }
+        // write to output
+        Console.WriteLine("Unicode string: " + semNameNum);
+        return semName;
+    }
+
+    public static string GetUniqueName()
+    {
+        string sName = Guid.NewGuid().ToString();
+        Console.WriteLine("Name created: " + sName);
+        return sName;
+    }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.cs
new file mode 100644 (file)
index 0000000..7711111
--- /dev/null
@@ -0,0 +1,32 @@
+using System;
+using System.Threading;
+using System.Diagnostics;
+
+public class AutoConstructFalse : EventWaitHandleTest
+{
+       public static int Main()
+       {
+               return RunTest(new Func<int>(Run));
+       }
+
+       public static int Run()
+       {
+               var sw = new Stopwatch();
+               var ewh = new EventWaitHandle(false, System.Threading.EventResetMode.AutoReset);
+
+               // Should not signal
+               if (ewh.TestWaitOne(1000, sw))
+                       return -1;
+
+               // Should signal
+               ewh.Set();
+               if (!ewh.TestWaitOne(0, null))
+                       return -2;
+
+               // Should not signal
+               if (ewh.TestWaitOne(1000, sw))
+                       return -3;
+               
+               return TestPassed;
+       }
+}
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.csproj
new file mode 100644 (file)
index 0000000..a8b1706
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{7e4cd64f-c8d1-491c-bf2e-72f841ec6813}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="AutoConstructFalse.cs" />
+    <Compile Include="EventWaitHandleTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.cs
new file mode 100644 (file)
index 0000000..b57994e
--- /dev/null
@@ -0,0 +1,25 @@
+using System;
+using System.Threading;
+using System.Diagnostics;
+
+public class AutoConstructTrue : EventWaitHandleTest
+{
+       public static int Main()
+       {
+               return RunTest(new Func<int>(Run));
+       }
+
+       public static int Run()
+       {
+               var ewh = new EventWaitHandle(true, EventResetMode.AutoReset);
+               var sw = new Stopwatch();
+               
+               if (!ewh.TestWaitOne(0, null))
+                       return -1;
+
+               if (ewh.TestWaitOne(1000, sw))
+                       return -2;
+
+               return TestPassed;
+       }
+}
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.csproj
new file mode 100644 (file)
index 0000000..1be4015
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{7e4cd64f-c8d1-491c-bf2e-72f841ec6813}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="AutoConstructTrue.cs" />
+    <Compile Include="EventWaitHandleTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/EventWaitHandleTest.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/EventWaitHandleTest.cs
new file mode 100644 (file)
index 0000000..da028fe
--- /dev/null
@@ -0,0 +1,57 @@
+using System;
+using System.Threading;
+using System.Diagnostics;
+
+public class EventWaitHandleTest
+{
+       public const int TestPassed = 100; // Returned by Run() on success
+
+       public static int RunTest(Func<int> test) {
+               var rv = test();
+               Console.WriteLine(rv == TestPassed ? "Test passed" : "Test failed");
+               return rv;
+       }
+
+       public static bool TryOpenExisting<Expected>(string name) where Expected : Exception
+       {
+               EventWaitHandle ewh;
+               return TryOpenExisting<Expected>(name, out ewh);
+       }
+
+       public static bool TryOpenExisting<Expected>(string name, out EventWaitHandle ewh) where Expected : Exception
+       {
+               ewh = null;
+               try {
+                       ewh = EventWaitHandle.OpenExisting(name);
+               } catch (Expected) {
+               } catch (Exception ne) {
+                       Console.WriteLine("Caught unexpected exception: {0}", ne);
+                       return false;
+               }
+               return true;
+       }
+
+       public class NoException : Exception {}
+}
+
+public static class EventWaitHandleExtensions
+{
+       const int FudgeFactor = 100; // Account for timing uncertainties
+
+       public static bool TestWaitOne(this EventWaitHandle ewh, int timeout, Stopwatch sw)
+       {
+               if (timeout == 0)
+                       return ewh.WaitOne();
+
+               if (sw == null)
+                       sw = new Stopwatch();
+               else
+                       sw.Reset();
+
+               sw.Start();
+               bool signaled = ewh.WaitOne(timeout);
+               sw.Stop();
+
+               return signaled || sw.ElapsedMilliseconds < timeout - FudgeFactor;
+       }
+}
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.cs
new file mode 100644 (file)
index 0000000..494d660
--- /dev/null
@@ -0,0 +1,33 @@
+using System;
+using System.Threading;
+using System.Diagnostics;
+
+public class ManualConstructFalse : EventWaitHandleTest
+{
+       public static int Main()
+       {
+               return RunTest(new Func<int>(Run));
+       }
+
+       public static int Run()
+       {
+               var sw = new Stopwatch();               
+               var ewh = new EventWaitHandle(false, EventResetMode.ManualReset);
+
+               // Should not signal
+               if (ewh.TestWaitOne(1000, sw))
+                       return -1;
+
+               // Should signal
+               ewh.Set();
+               if (!ewh.TestWaitOne(0, sw))
+                       return -2;
+
+               // Should not signal
+               ewh.Reset();
+               if (ewh.TestWaitOne(1000, sw))
+                       return -3;
+
+               return TestPassed;
+       }
+}
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.csproj
new file mode 100644 (file)
index 0000000..fb35a4b
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{7e4cd64f-c8d1-491c-bf2e-72f841ec6813}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ManualConstructFalse.cs" />
+    <Compile Include="EventWaitHandleTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.cs
new file mode 100644 (file)
index 0000000..a9ad7cc
--- /dev/null
@@ -0,0 +1,31 @@
+using System;
+using System.Threading;
+
+public class ManualConstructTrue : EventWaitHandleTest
+{
+       public static int Main()
+       {
+               return RunTest(new Func<int>(Run));
+       }
+
+       public static int Run()
+       {
+               var ewh = new EventWaitHandle(true, EventResetMode.ManualReset);
+
+               // Should signal
+               if (!ewh.TestWaitOne(0, null))
+                       return -1;
+
+               // Should not signal
+               ewh.Reset();
+               if (ewh.TestWaitOne(1000, null))
+                       return -2;
+
+               // Should signal
+               ewh.Set();
+               if (!ewh.TestWaitOne(0, null))
+                       return -3;
+
+               return TestPassed;              
+       }
+}
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.csproj
new file mode 100644 (file)
index 0000000..687fb2d
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{7e4cd64f-c8d1-491c-bf2e-72f841ec6813}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ManualConstructTrue.cs" />
+    <Compile Include="EventWaitHandleTest.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/project.json b/tests/src/baseservices/threading/events/EventWaitHandle/unit/project.json
new file mode 100644 (file)
index 0000000..c14efc6
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.cs b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.cs
new file mode 100644 (file)
index 0000000..566edef
--- /dev/null
@@ -0,0 +1,55 @@
+using System;
+using System.Threading;
+using System.Diagnostics;
+
+public class MRETestClass
+{
+
+       public static int Main()
+       {
+               MRETestClass testManualReset = new MRETestClass();
+               int ret = testManualReset.Run();
+               Console.WriteLine(ret == 100 ? "Test Passed":"Test Failed");
+               return ret;
+       }
+
+       public int Run()
+       {
+               Stopwatch sw = new Stopwatch();         
+               ManualResetEvent mre = new ManualResetEvent(false);
+               sw.Start();
+               bool ret = mre.WaitOne(1000);//,false);
+               sw.Stop();
+               //We should never get signaled
+               Console.WriteLine("Expect WaitOne to return False and time-out after 1000 milliseconds waiting for signal.");
+               Console.WriteLine("Actual return is: " + ret.ToString());
+               Console.WriteLine("Expect Stopwatch to use entire 1000 milliseconds.");
+               Console.WriteLine("Actual time taken is: " + sw.ElapsedMilliseconds.ToString());
+               Console.WriteLine();
+               if(ret || sw.ElapsedMilliseconds < 900)
+                       return -1;
+               Console.WriteLine("Manual Reset Event signalled.");             
+               mre.Set();
+               ret = mre.WaitOne(0);//,false);
+               Console.WriteLine("Expect WaitOne to return True and time-out after 1000 milliseconds waiting for signal.");
+               Console.WriteLine("Actual return is: " + ret.ToString());
+               Console.WriteLine();            
+               if(!ret)                        
+                       return -3;
+               mre.Reset();
+               sw.Reset();
+               sw.Start();
+               ret = mre.WaitOne(1000);//,false);
+               sw.Stop();
+               //We should never get signaled
+               Console.WriteLine("Expect WaitOne to return false and time-out after 1000 milliseconds waiting for signal.");
+               Console.WriteLine("Actual return is: " + ret.ToString());
+               Console.WriteLine("Expect Stopwatch to use entire 1000 milliseconds.");
+               Console.WriteLine("Actual time taken is: " + sw.ElapsedMilliseconds.ToString());                                
+               if(ret || sw.ElapsedMilliseconds < 900)
+                       return -1;
+               
+               return 100;
+               
+       }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.csproj b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.csproj
new file mode 100644 (file)
index 0000000..6f5e35c
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{717a283b-e0af-4ef2-b072-0378decb2d96}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ConstructFalse.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.cs b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.cs
new file mode 100644 (file)
index 0000000..26ea5b3
--- /dev/null
@@ -0,0 +1,33 @@
+using System;
+using System.Threading;
+
+public class MRETestClass
+{
+
+       public static int Main()
+       {
+               MRETestClass testManualReset = new MRETestClass();
+
+               int ret = testManualReset.Run();
+               Console.WriteLine(ret == 100 ? "Test Passed":"Test Failed");
+               return ret;
+       }
+
+       public int Run()
+       {
+               ManualResetEvent mre = new ManualResetEvent(true);
+               
+               if(!mre.WaitOne(0))//,false)) //are.WaitOne returns true if signaled
+                       return -1;
+               mre.Reset();
+               if(mre.WaitOne(1000))//,false))
+                       return -3;
+               mre.Set();              
+               if(mre.WaitOne(0))//,false))
+                       return 100;
+               
+               Console.WriteLine("ManualResetEvent Broken");
+               return -3;
+               
+       }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.csproj b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.csproj
new file mode 100644 (file)
index 0000000..c83e641
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{717a283b-e0af-4ef2-b072-0378decb2d96}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="ConstructTrue.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/project.json b/tests/src/baseservices/threading/events/ManualResetEvent/project.json
new file mode 100644 (file)
index 0000000..c14efc6
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit01.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit01.cs
new file mode 100644 (file)
index 0000000..e175cdb
--- /dev/null
@@ -0,0 +1,91 @@
+using System;
+using System.Threading;
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+class Gen<T> 
+{
+       public static void EnterExitTest()
+       {
+               Type monitor = typeof(Gen<T>);
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads];
+               // for(int i=0;i<consumer.Length;i++){
+               //      consumer[i] = new MonitorDelegate(myHelper.Consumer);
+               //      consumer[i].BeginInvoke(monitor,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitor);
+                       });
+               }
+
+               for(int i=0;i<6;i++){
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }       
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.EnterExitTest();       
+               Gen<double>.EnterExitTest();
+               Gen<string>.EnterExitTest();
+               Gen<object>.EnterExitTest();
+               Gen<Guid>.EnterExitTest();
+
+               Gen<int[]>.EnterExitTest();
+               Gen<double[,]>.EnterExitTest();
+               Gen<string[][][]>.EnterExitTest();
+               Gen<object[,,,]>.EnterExitTest();
+               Gen<Guid[][,,,][]>.EnterExitTest();
+
+               Gen<RefX1<int>[]>.EnterExitTest();
+               Gen<RefX1<double>[,]>.EnterExitTest();
+               Gen<RefX1<string>[][][]>.EnterExitTest();
+               Gen<RefX1<object>[,,,]>.EnterExitTest();
+               Gen<RefX1<Guid>[][,,,][]>.EnterExitTest();
+
+               Gen<ValX1<int>[]>.EnterExitTest();
+               Gen<ValX1<double>[,]>.EnterExitTest();
+               Gen<ValX1<string>[][][]>.EnterExitTest();
+               Gen<ValX1<object>[,,,]>.EnterExitTest();
+               Gen<ValX1<Guid>[][,,,][]>.EnterExitTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit01.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit01.csproj
new file mode 100644 (file)
index 0000000..3665d59
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit01.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit02.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit02.cs
new file mode 100644 (file)
index 0000000..30829c4
--- /dev/null
@@ -0,0 +1,164 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+class Gen<T> 
+{
+       public static void EnterExitTest<U>()
+       {
+               Type monitorT = typeof(Gen<T>);
+               Type monitorU = typeof(Gen<U>);
+
+               if(monitorU.Equals(monitorT))
+                       throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG");
+
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               TestHelper myHelper2 = new TestHelper(Test.nThreads);
+               WaitHandle[] myWaiter = new WaitHandle[2];
+               myWaiter[0] = myHelper.m_Event;
+               myWaiter[1] = myHelper2.m_Event;
+
+               for(int i=0;i<Test.nThreads;i++)
+               {
+                       // new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null);
+                       // new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null);
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitorT);
+                       });
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper2.Consumer(monitorU);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {       
+                       if(WaitHandle.WaitAll(myWaiter,10000))//,true))
+                               break;
+                       if(myHelper.Error == true || myHelper2.Error == true)
+                               break;
+               }
+               Test.Eval(!(myHelper.Error && myHelper2.Error));
+       }
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<double>.EnterExitTest<int>();
+               Gen<string>.EnterExitTest<int>();
+               Gen<object>.EnterExitTest<int>();
+               Gen<Guid>.EnterExitTest<int>();
+               Gen<RefX1<int>>.EnterExitTest<int>();
+               Gen<RefX1<string>>.EnterExitTest<int>();
+               Gen<ValX1<int>>.EnterExitTest<int>();
+               Gen<ValX1<string>>.EnterExitTest<int>();
+               
+               Gen<int>.EnterExitTest<double>();       
+               Gen<string>.EnterExitTest<double>();
+               Gen<object>.EnterExitTest<double>();
+               Gen<Guid>.EnterExitTest<double>();
+               Gen<RefX1<int>>.EnterExitTest<double>();
+               Gen<RefX1<string>>.EnterExitTest<double>();
+               Gen<ValX1<int>>.EnterExitTest<double>();
+               Gen<ValX1<string>>.EnterExitTest<double>();
+
+               Gen<int>.EnterExitTest<string>();       
+               Gen<double>.EnterExitTest<string>();
+               Gen<object>.EnterExitTest<string>();
+               Gen<Guid>.EnterExitTest<string>();
+               Gen<RefX1<int>>.EnterExitTest<string>();
+               Gen<RefX1<string>>.EnterExitTest<string>();
+               Gen<ValX1<int>>.EnterExitTest<string>();
+               Gen<ValX1<string>>.EnterExitTest<string>();
+
+               Gen<int>.EnterExitTest<object>();       
+               Gen<double>.EnterExitTest<object>();
+               Gen<string>.EnterExitTest<object>();
+               Gen<Guid>.EnterExitTest<object>();
+               Gen<RefX1<int>>.EnterExitTest<object>();
+               Gen<RefX1<string>>.EnterExitTest<object>();
+               Gen<ValX1<int>>.EnterExitTest<object>();
+               Gen<ValX1<string>>.EnterExitTest<object>();
+
+               Gen<int>.EnterExitTest<Guid>(); 
+               Gen<double>.EnterExitTest<Guid>();
+               Gen<string>.EnterExitTest<Guid>();
+               Gen<object>.EnterExitTest<Guid>();
+               Gen<RefX1<int>>.EnterExitTest<Guid>();
+               Gen<RefX1<string>>.EnterExitTest<Guid>();
+               Gen<ValX1<int>>.EnterExitTest<Guid>();
+               Gen<ValX1<string>>.EnterExitTest<Guid>();
+
+               Gen<int>.EnterExitTest<RefX1<int>>();   
+               Gen<double>.EnterExitTest<RefX1<int>>();
+               Gen<string>.EnterExitTest<RefX1<int>>();
+               Gen<object>.EnterExitTest<RefX1<int>>();
+               Gen<Guid>.EnterExitTest<RefX1<int>>();
+               Gen<RefX1<string>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); 
+
+               Gen<int>.EnterExitTest<RefX1<string>>();        
+               Gen<double>.EnterExitTest<RefX1<string>>();
+               Gen<string>.EnterExitTest<RefX1<string>>();
+               Gen<object>.EnterExitTest<RefX1<string>>();
+               Gen<Guid>.EnterExitTest<RefX1<string>>();
+               Gen<RefX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<string>>();
+
+               Gen<int>.EnterExitTest<ValX1<int>>();   
+               Gen<double>.EnterExitTest<ValX1<int>>();
+               Gen<string>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<int>>();
+               Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+
+               Gen<int>.EnterExitTest<ValX1<string>>();        //offending line
+               Gen<double>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<string>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit02.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit02.csproj
new file mode 100644 (file)
index 0000000..50ce3c3
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit02.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit03.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit03.cs
new file mode 100644 (file)
index 0000000..1e0d2f4
--- /dev/null
@@ -0,0 +1,96 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+
+struct Gen<T> 
+{
+       public static void EnterExitTest()
+       {
+               Type monitor = typeof(Gen<T>);          
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads];
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      consumer[i] = new MonitorDelegate(myHelper.Consumer);
+               //      consumer[i].BeginInvoke(monitor,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitor);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.EnterExitTest();       
+               Gen<double>.EnterExitTest();
+               Gen<string>.EnterExitTest();
+               Gen<object>.EnterExitTest();
+               Gen<Guid>.EnterExitTest();
+
+               Gen<int[]>.EnterExitTest();
+               Gen<double[,]>.EnterExitTest();
+               Gen<string[][][]>.EnterExitTest();
+               Gen<object[,,,]>.EnterExitTest();
+               Gen<Guid[][,,,][]>.EnterExitTest();
+
+               Gen<RefX1<int>[]>.EnterExitTest();
+               Gen<RefX1<double>[,]>.EnterExitTest();
+               Gen<RefX1<string>[][][]>.EnterExitTest();
+               Gen<RefX1<object>[,,,]>.EnterExitTest();
+               Gen<RefX1<Guid>[][,,,][]>.EnterExitTest();
+
+               Gen<ValX1<int>[]>.EnterExitTest();
+               Gen<ValX1<double>[,]>.EnterExitTest();
+               Gen<ValX1<string>[][][]>.EnterExitTest();
+               Gen<ValX1<object>[,,,]>.EnterExitTest();
+               Gen<ValX1<Guid>[][,,,][]>.EnterExitTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit03.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit03.csproj
new file mode 100644 (file)
index 0000000..5aa2376
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit03.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit04.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit04.cs
new file mode 100644 (file)
index 0000000..2184f5c
--- /dev/null
@@ -0,0 +1,169 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+
+struct Gen<T> 
+{
+       public static void EnterExitTest<U>()
+       {
+               Type monitorT = typeof(Gen<T>);
+               Type monitorU = typeof(Gen<U>);
+
+               if(monitorU.Equals(monitorT))
+                       throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG");
+                               
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               TestHelper myHelper2 = new TestHelper(Test.nThreads);
+               WaitHandle[] myWaiter = new WaitHandle[2];
+               myWaiter[0] = myHelper.m_Event;
+               myWaiter[1] = myHelper2.m_Event;
+
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null);
+               //      new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null);
+               // }
+
+               for(int i=0; i<Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitorT);
+                       });
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper2.Consumer(monitorU);
+                       });
+               }
+
+
+               for(int i=0;i<6;i++)
+               {       
+                       if(WaitHandle.WaitAll(myWaiter,10000))//,true))
+                               break;
+                       if(myHelper.Error == true || myHelper2.Error == true)
+                               break;
+               }
+               Test.Eval(!(myHelper.Error && myHelper2.Error));
+       }       
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<double>.EnterExitTest<int>();
+               Gen<string>.EnterExitTest<int>();
+               Gen<object>.EnterExitTest<int>();
+               Gen<Guid>.EnterExitTest<int>();
+               Gen<RefX1<int>>.EnterExitTest<int>();
+               Gen<RefX1<string>>.EnterExitTest<int>();
+               Gen<ValX1<int>>.EnterExitTest<int>();
+               Gen<ValX1<string>>.EnterExitTest<int>();
+               
+               Gen<int>.EnterExitTest<double>();       
+               Gen<string>.EnterExitTest<double>();
+               Gen<object>.EnterExitTest<double>();
+               Gen<Guid>.EnterExitTest<double>();
+               Gen<RefX1<int>>.EnterExitTest<double>();
+               Gen<RefX1<string>>.EnterExitTest<double>();
+               Gen<ValX1<int>>.EnterExitTest<double>();
+               Gen<ValX1<string>>.EnterExitTest<double>();
+
+               Gen<int>.EnterExitTest<string>();       
+               Gen<double>.EnterExitTest<string>();
+               Gen<object>.EnterExitTest<string>();
+               Gen<Guid>.EnterExitTest<string>();
+               Gen<RefX1<int>>.EnterExitTest<string>();
+               Gen<RefX1<string>>.EnterExitTest<string>();
+               Gen<ValX1<int>>.EnterExitTest<string>();
+               Gen<ValX1<string>>.EnterExitTest<string>();
+
+               Gen<int>.EnterExitTest<object>();       
+               Gen<double>.EnterExitTest<object>();
+               Gen<string>.EnterExitTest<object>();
+               Gen<Guid>.EnterExitTest<object>();
+               Gen<RefX1<int>>.EnterExitTest<object>();
+               Gen<RefX1<string>>.EnterExitTest<object>();
+               Gen<ValX1<int>>.EnterExitTest<object>();
+               Gen<ValX1<string>>.EnterExitTest<object>();
+
+               Gen<int>.EnterExitTest<Guid>(); 
+               Gen<double>.EnterExitTest<Guid>();
+               Gen<string>.EnterExitTest<Guid>();
+               Gen<object>.EnterExitTest<Guid>();
+               Gen<RefX1<int>>.EnterExitTest<Guid>();
+               Gen<RefX1<string>>.EnterExitTest<Guid>();
+               Gen<ValX1<int>>.EnterExitTest<Guid>();
+               Gen<ValX1<string>>.EnterExitTest<Guid>();
+
+               Gen<int>.EnterExitTest<RefX1<int>>();   
+               Gen<double>.EnterExitTest<RefX1<int>>();
+               Gen<string>.EnterExitTest<RefX1<int>>();
+               Gen<object>.EnterExitTest<RefX1<int>>();
+               Gen<Guid>.EnterExitTest<RefX1<int>>();
+               Gen<RefX1<string>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); 
+
+               Gen<int>.EnterExitTest<RefX1<string>>();        
+               Gen<double>.EnterExitTest<RefX1<string>>();
+               Gen<string>.EnterExitTest<RefX1<string>>();
+               Gen<object>.EnterExitTest<RefX1<string>>();
+               Gen<Guid>.EnterExitTest<RefX1<string>>();
+               Gen<RefX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<string>>();
+
+               Gen<int>.EnterExitTest<ValX1<int>>();   
+               Gen<double>.EnterExitTest<ValX1<int>>();
+               Gen<string>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<int>>();
+               Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+
+               Gen<int>.EnterExitTest<ValX1<string>>();        //offending line
+               Gen<double>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<string>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit04.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit04.csproj
new file mode 100644 (file)
index 0000000..37d7fd6
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit04.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit05.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit05.cs
new file mode 100644 (file)
index 0000000..b879d2a
--- /dev/null
@@ -0,0 +1,96 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+class Gen<T> 
+{
+       public static void EnterExitTest()
+       {
+               Type monitor = typeof(Gen<T>).GetGenericTypeDefinition();               
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               
+               // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads];
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      consumer[i] = new MonitorDelegate(myHelper.Consumer);
+               //      consumer[i].BeginInvoke(monitor,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitor);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }       
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.EnterExitTest();       
+               Gen<double>.EnterExitTest();
+               Gen<string>.EnterExitTest();
+               Gen<object>.EnterExitTest();
+               Gen<Guid>.EnterExitTest();
+
+               Gen<int[]>.EnterExitTest();
+               Gen<double[,]>.EnterExitTest();
+               Gen<string[][][]>.EnterExitTest();
+               Gen<object[,,,]>.EnterExitTest();
+               Gen<Guid[][,,,][]>.EnterExitTest();
+
+               Gen<RefX1<int>[]>.EnterExitTest();
+               Gen<RefX1<double>[,]>.EnterExitTest();
+               Gen<RefX1<string>[][][]>.EnterExitTest();
+               Gen<RefX1<object>[,,,]>.EnterExitTest();
+               Gen<RefX1<Guid>[][,,,][]>.EnterExitTest();
+
+               Gen<ValX1<int>[]>.EnterExitTest();
+               Gen<ValX1<double>[,]>.EnterExitTest();
+               Gen<ValX1<string>[][][]>.EnterExitTest();
+               Gen<ValX1<object>[,,,]>.EnterExitTest();
+               Gen<ValX1<Guid>[][,,,][]>.EnterExitTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit05.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit05.csproj
new file mode 100644 (file)
index 0000000..087c377
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit05.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit06.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit06.cs
new file mode 100644 (file)
index 0000000..65c4f95
--- /dev/null
@@ -0,0 +1,168 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+class Gen<T> 
+{
+       public static void EnterExitTest<U>()
+       {
+               Type monitorT = typeof(Gen<T>).GetGenericTypeDefinition();
+               Type monitorU = typeof(Gen<U>).GetGenericTypeDefinition();
+
+               if(!monitorU.Equals(monitorT))
+                       throw new Exception("Invalid use of test case, T must be equal to U - POSSIBLE TYPE SYSTEM BUG");
+                               
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               TestHelper myHelper2 = new TestHelper(Test.nThreads);
+               WaitHandle[] myWaiter = new WaitHandle[2];
+               myWaiter[0] = myHelper.m_Event;
+               myWaiter[1] = myHelper2.m_Event;
+               
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null);
+               //      new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null);
+               // }
+
+               for(int i=0;i<Test.nThreads;i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitorT);
+                       });
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper2.Consumer(monitorU);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {       
+                       if(WaitHandle.WaitAll(myWaiter,10000))//,true))
+                               break;
+                       if(myHelper.Error == true || myHelper2.Error == true)
+                               break;
+               }
+               Test.Eval(!(myHelper.Error && myHelper2.Error));
+       }
+       
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<double>.EnterExitTest<int>();
+               Gen<string>.EnterExitTest<int>();
+               Gen<object>.EnterExitTest<int>();
+               Gen<Guid>.EnterExitTest<int>();
+               Gen<RefX1<int>>.EnterExitTest<int>();
+               Gen<RefX1<string>>.EnterExitTest<int>();
+               Gen<ValX1<int>>.EnterExitTest<int>();
+               Gen<ValX1<string>>.EnterExitTest<int>();
+               
+               Gen<int>.EnterExitTest<double>();       
+               Gen<string>.EnterExitTest<double>();
+               Gen<object>.EnterExitTest<double>();
+               Gen<Guid>.EnterExitTest<double>();
+               Gen<RefX1<int>>.EnterExitTest<double>();
+               Gen<RefX1<string>>.EnterExitTest<double>();
+               Gen<ValX1<int>>.EnterExitTest<double>();
+               Gen<ValX1<string>>.EnterExitTest<double>();
+
+               Gen<int>.EnterExitTest<string>();       
+               Gen<double>.EnterExitTest<string>();
+               Gen<object>.EnterExitTest<string>();
+               Gen<Guid>.EnterExitTest<string>();
+               Gen<RefX1<int>>.EnterExitTest<string>();
+               Gen<RefX1<string>>.EnterExitTest<string>();
+               Gen<ValX1<int>>.EnterExitTest<string>();
+               Gen<ValX1<string>>.EnterExitTest<string>();
+
+               Gen<int>.EnterExitTest<object>();       
+               Gen<double>.EnterExitTest<object>();
+               Gen<string>.EnterExitTest<object>();
+               Gen<Guid>.EnterExitTest<object>();
+               Gen<RefX1<int>>.EnterExitTest<object>();
+               Gen<RefX1<string>>.EnterExitTest<object>();
+               Gen<ValX1<int>>.EnterExitTest<object>();
+               Gen<ValX1<string>>.EnterExitTest<object>();
+
+               Gen<int>.EnterExitTest<Guid>(); 
+               Gen<double>.EnterExitTest<Guid>();
+               Gen<string>.EnterExitTest<Guid>();
+               Gen<object>.EnterExitTest<Guid>();
+               Gen<RefX1<int>>.EnterExitTest<Guid>();
+               Gen<RefX1<string>>.EnterExitTest<Guid>();
+               Gen<ValX1<int>>.EnterExitTest<Guid>();
+               Gen<ValX1<string>>.EnterExitTest<Guid>();
+
+               Gen<int>.EnterExitTest<RefX1<int>>();   
+               Gen<double>.EnterExitTest<RefX1<int>>();
+               Gen<string>.EnterExitTest<RefX1<int>>();
+               Gen<object>.EnterExitTest<RefX1<int>>();
+               Gen<Guid>.EnterExitTest<RefX1<int>>();
+               Gen<RefX1<string>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); 
+
+               Gen<int>.EnterExitTest<RefX1<string>>();        
+               Gen<double>.EnterExitTest<RefX1<string>>();
+               Gen<string>.EnterExitTest<RefX1<string>>();
+               Gen<object>.EnterExitTest<RefX1<string>>();
+               Gen<Guid>.EnterExitTest<RefX1<string>>();
+               Gen<RefX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<string>>();
+
+               Gen<int>.EnterExitTest<ValX1<int>>();   
+               Gen<double>.EnterExitTest<ValX1<int>>();
+               Gen<string>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<int>>();
+               Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+
+               Gen<int>.EnterExitTest<ValX1<string>>();        //offending line
+               Gen<double>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<string>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit06.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit06.csproj
new file mode 100644 (file)
index 0000000..a8d45d0
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit06.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit07.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit07.cs
new file mode 100644 (file)
index 0000000..3ced28e
--- /dev/null
@@ -0,0 +1,95 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+struct Gen<T> 
+{
+       public static void EnterExitTest()
+       {
+               Type monitor = typeof(Gen<T>).GetGenericTypeDefinition();               
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads];
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      consumer[i] = new MonitorDelegate(myHelper.Consumer);
+               //      consumer[i].BeginInvoke(monitor,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitor);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }       
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.EnterExitTest();       
+               Gen<double>.EnterExitTest();
+               Gen<string>.EnterExitTest();
+               Gen<object>.EnterExitTest();
+               Gen<Guid>.EnterExitTest();
+
+               Gen<int[]>.EnterExitTest();
+               Gen<double[,]>.EnterExitTest();
+               Gen<string[][][]>.EnterExitTest();
+               Gen<object[,,,]>.EnterExitTest();
+               Gen<Guid[][,,,][]>.EnterExitTest();
+
+               Gen<RefX1<int>[]>.EnterExitTest();
+               Gen<RefX1<double>[,]>.EnterExitTest();
+               Gen<RefX1<string>[][][]>.EnterExitTest();
+               Gen<RefX1<object>[,,,]>.EnterExitTest();
+               Gen<RefX1<Guid>[][,,,][]>.EnterExitTest();
+
+               Gen<ValX1<int>[]>.EnterExitTest();
+               Gen<ValX1<double>[,]>.EnterExitTest();
+               Gen<ValX1<string>[][][]>.EnterExitTest();
+               Gen<ValX1<object>[,,,]>.EnterExitTest();
+               Gen<ValX1<Guid>[][,,,][]>.EnterExitTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit07.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit07.csproj
new file mode 100644 (file)
index 0000000..2ee283f
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit07.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit08.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit08.cs
new file mode 100644 (file)
index 0000000..5f1d3a8
--- /dev/null
@@ -0,0 +1,168 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+
+struct Gen<T> 
+{
+       public static void EnterExitTest<U>()
+       {
+               Type monitorT = typeof(Gen<T>).GetGenericTypeDefinition();
+               Type monitorU = typeof(Gen<U>).GetGenericTypeDefinition();
+
+               if(!monitorU.Equals(monitorT))
+                       throw new Exception("Invalid use of test case, T must be equal to U - POSSIBLE TYPE SYSTEM BUG");
+                               
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               TestHelper myHelper2 = new TestHelper(Test.nThreads);
+               WaitHandle[] myWaiter = new WaitHandle[2];
+               myWaiter[0] = myHelper.m_Event;
+               myWaiter[1] = myHelper2.m_Event;
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null);
+               //      new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null);
+               // }
+
+               for(int i=0;i<Test.nThreads;i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitorT);
+                       });
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper2.Consumer(monitorU);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {       
+                       if(WaitHandle.WaitAll(myWaiter,10000))//,true))
+                               break;
+                       if(myHelper.Error == true || myHelper2.Error == true)
+                               break;
+               }
+               Test.Eval(!(myHelper.Error && myHelper2.Error));
+       }
+       
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<double>.EnterExitTest<int>();
+               Gen<string>.EnterExitTest<int>();
+               Gen<object>.EnterExitTest<int>();
+               Gen<Guid>.EnterExitTest<int>();
+               Gen<RefX1<int>>.EnterExitTest<int>();
+               Gen<RefX1<string>>.EnterExitTest<int>();
+               Gen<ValX1<int>>.EnterExitTest<int>();
+               Gen<ValX1<string>>.EnterExitTest<int>();
+               
+               Gen<int>.EnterExitTest<double>();       
+               Gen<string>.EnterExitTest<double>();
+               Gen<object>.EnterExitTest<double>();
+               Gen<Guid>.EnterExitTest<double>();
+               Gen<RefX1<int>>.EnterExitTest<double>();
+               Gen<RefX1<string>>.EnterExitTest<double>();
+               Gen<ValX1<int>>.EnterExitTest<double>();
+               Gen<ValX1<string>>.EnterExitTest<double>();
+
+               Gen<int>.EnterExitTest<string>();       
+               Gen<double>.EnterExitTest<string>();
+               Gen<object>.EnterExitTest<string>();
+               Gen<Guid>.EnterExitTest<string>();
+               Gen<RefX1<int>>.EnterExitTest<string>();
+               Gen<RefX1<string>>.EnterExitTest<string>();
+               Gen<ValX1<int>>.EnterExitTest<string>();
+               Gen<ValX1<string>>.EnterExitTest<string>();
+
+               Gen<int>.EnterExitTest<object>();       
+               Gen<double>.EnterExitTest<object>();
+               Gen<string>.EnterExitTest<object>();
+               Gen<Guid>.EnterExitTest<object>();
+               Gen<RefX1<int>>.EnterExitTest<object>();
+               Gen<RefX1<string>>.EnterExitTest<object>();
+               Gen<ValX1<int>>.EnterExitTest<object>();
+               Gen<ValX1<string>>.EnterExitTest<object>();
+
+               Gen<int>.EnterExitTest<Guid>(); 
+               Gen<double>.EnterExitTest<Guid>();
+               Gen<string>.EnterExitTest<Guid>();
+               Gen<object>.EnterExitTest<Guid>();
+               Gen<RefX1<int>>.EnterExitTest<Guid>();
+               Gen<RefX1<string>>.EnterExitTest<Guid>();
+               Gen<ValX1<int>>.EnterExitTest<Guid>();
+               Gen<ValX1<string>>.EnterExitTest<Guid>();
+
+               Gen<int>.EnterExitTest<RefX1<int>>();   
+               Gen<double>.EnterExitTest<RefX1<int>>();
+               Gen<string>.EnterExitTest<RefX1<int>>();
+               Gen<object>.EnterExitTest<RefX1<int>>();
+               Gen<Guid>.EnterExitTest<RefX1<int>>();
+               Gen<RefX1<string>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); 
+
+               Gen<int>.EnterExitTest<RefX1<string>>();        
+               Gen<double>.EnterExitTest<RefX1<string>>();
+               Gen<string>.EnterExitTest<RefX1<string>>();
+               Gen<object>.EnterExitTest<RefX1<string>>();
+               Gen<Guid>.EnterExitTest<RefX1<string>>();
+               Gen<RefX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<string>>();
+
+               Gen<int>.EnterExitTest<ValX1<int>>();   
+               Gen<double>.EnterExitTest<ValX1<int>>();
+               Gen<string>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<int>>();
+               Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+
+               Gen<int>.EnterExitTest<ValX1<string>>();        //offending line
+               Gen<double>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<string>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit08.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit08.csproj
new file mode 100644 (file)
index 0000000..d485558
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit08.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit09.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit09.cs
new file mode 100644 (file)
index 0000000..d39cf8c
--- /dev/null
@@ -0,0 +1,94 @@
+using System;
+using System.Threading;
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+class Gen<T> 
+{
+       public static void EnterExitTest()
+       {
+               Gen<T> monitor = new Gen<T>();          
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads];
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      consumer[i] = new MonitorDelegate(myHelper.Consumer);
+               //      consumer[i].BeginInvoke(monitor,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitor);
+                       });
+               }
+               
+               for(int i=0;i<6;i++)
+               {
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }       
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.EnterExitTest();       
+               Gen<double>.EnterExitTest();
+               Gen<string>.EnterExitTest();
+               Gen<object>.EnterExitTest();
+               Gen<Guid>.EnterExitTest();
+
+               Gen<int[]>.EnterExitTest();
+               Gen<double[,]>.EnterExitTest();
+               Gen<string[][][]>.EnterExitTest();
+               Gen<object[,,,]>.EnterExitTest();
+               Gen<Guid[][,,,][]>.EnterExitTest();
+
+               Gen<RefX1<int>[]>.EnterExitTest();
+               Gen<RefX1<double>[,]>.EnterExitTest();
+               Gen<RefX1<string>[][][]>.EnterExitTest();
+               Gen<RefX1<object>[,,,]>.EnterExitTest();
+               Gen<RefX1<Guid>[][,,,][]>.EnterExitTest();
+
+               Gen<ValX1<int>[]>.EnterExitTest();
+               Gen<ValX1<double>[,]>.EnterExitTest();
+               Gen<ValX1<string>[][][]>.EnterExitTest();
+               Gen<ValX1<object>[,,,]>.EnterExitTest();
+               Gen<ValX1<Guid>[][,,,][]>.EnterExitTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit09.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit09.csproj
new file mode 100644 (file)
index 0000000..8acf694
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit09.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit10.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit10.cs
new file mode 100644 (file)
index 0000000..710e929
--- /dev/null
@@ -0,0 +1,110 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+
+class Gen<T> 
+{
+       public static void EnterExitTest()
+       {
+               Gen<T> monitorT = new Gen<T>();
+               Gen<T> monitorU = new Gen<T>();
+               
+               if(monitorU.Equals(monitorT))
+                       throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG");
+                               
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               TestHelper myHelper2 = new TestHelper(Test.nThreads);
+               WaitHandle[] myWaiter = new WaitHandle[2];
+               myWaiter[0] = myHelper.m_Event;
+               myWaiter[1] = myHelper2.m_Event;
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null);
+               //      new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null);
+               // }
+
+               for(int i=0;i<Test.nThreads;i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitorT);
+                       });
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper2.Consumer(monitorU);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {       
+                       if(WaitHandle.WaitAll(myWaiter,10000))//,true))
+                               break;
+                       if(myHelper.Error == true || myHelper2.Error == true)
+                               break;
+               }
+               Test.Eval(!(myHelper.Error && myHelper2.Error));
+       }
+
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.EnterExitTest();       
+               Gen<double>.EnterExitTest();
+               Gen<string>.EnterExitTest();
+               Gen<object>.EnterExitTest();
+               Gen<Guid>.EnterExitTest();
+
+               Gen<int[]>.EnterExitTest();
+               Gen<double[,]>.EnterExitTest();
+               Gen<string[][][]>.EnterExitTest();
+               Gen<object[,,,]>.EnterExitTest();
+               Gen<Guid[][,,,][]>.EnterExitTest();
+
+               Gen<RefX1<int>[]>.EnterExitTest();
+               Gen<RefX1<double>[,]>.EnterExitTest();
+               Gen<RefX1<string>[][][]>.EnterExitTest();
+               Gen<RefX1<object>[,,,]>.EnterExitTest();
+               Gen<RefX1<Guid>[][,,,][]>.EnterExitTest();
+
+               Gen<ValX1<int>[]>.EnterExitTest();
+               Gen<ValX1<double>[,]>.EnterExitTest();
+               Gen<ValX1<string>[][][]>.EnterExitTest();
+               Gen<ValX1<object>[,,,]>.EnterExitTest();
+               Gen<ValX1<Guid>[][,,,][]>.EnterExitTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit10.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit10.csproj
new file mode 100644 (file)
index 0000000..9c21754
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit10.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit11.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit11.cs
new file mode 100644 (file)
index 0000000..7d00e28
--- /dev/null
@@ -0,0 +1,99 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+
+class Gen<T> 
+{
+       public static object staticLock;
+
+       public static void EnterExitTest()
+       {
+
+               Gen<T>.staticLock = new object();
+               
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads];
+               // for(int i=0;i<consumer.Length;i++){
+               //      consumer[i] = new MonitorDelegate(myHelper.Consumer);
+               //      consumer[i].BeginInvoke(staticLock,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(staticLock);
+                       });
+               }
+
+               for(int i=0;i<6;i++){
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }
+}
+
+public class Test
+{
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.EnterExitTest();       
+               Gen<double>.EnterExitTest();
+               Gen<string>.EnterExitTest();
+               Gen<object>.EnterExitTest();
+               Gen<Guid>.EnterExitTest();
+
+               Gen<int[]>.EnterExitTest();
+               Gen<double[,]>.EnterExitTest();
+               Gen<string[][][]>.EnterExitTest();
+               Gen<object[,,,]>.EnterExitTest();
+               Gen<Guid[][,,,][]>.EnterExitTest();
+
+               Gen<RefX1<int>[]>.EnterExitTest();
+               Gen<RefX1<double>[,]>.EnterExitTest();
+               Gen<RefX1<string>[][][]>.EnterExitTest();
+               Gen<RefX1<object>[,,,]>.EnterExitTest();
+               Gen<RefX1<Guid>[][,,,][]>.EnterExitTest();
+
+               Gen<ValX1<int>[]>.EnterExitTest();
+               Gen<ValX1<double>[,]>.EnterExitTest();
+               Gen<ValX1<string>[][][]>.EnterExitTest();
+               Gen<ValX1<object>[,,,]>.EnterExitTest();
+               Gen<ValX1<Guid>[][,,,][]>.EnterExitTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit11.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit11.csproj
new file mode 100644 (file)
index 0000000..ac09daa
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit11.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit12.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit12.cs
new file mode 100644 (file)
index 0000000..99ea686
--- /dev/null
@@ -0,0 +1,176 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+class Gen<T> 
+{
+       public static object staticLock;
+
+       public static void EnterExitTest<U>()
+       {
+               
+               Gen<T>.staticLock = new object();
+               Gen<U>.staticLock = new object();
+
+               object monitorT = Gen<T>.staticLock;
+               object monitorU = Gen<U>.staticLock;
+
+               if(monitorU.Equals(monitorT))
+                       throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG");
+
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               TestHelper myHelper2 = new TestHelper(Test.nThreads);
+               WaitHandle[] myWaiter = new WaitHandle[2];
+               myWaiter[0] = myHelper.m_Event;
+               myWaiter[1] = myHelper2.m_Event;
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null);
+               //      new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null);
+               // }
+
+               for(int i=0; i<Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitorT);
+                       });
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper2.Consumer(monitorU);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {       
+                       if(WaitHandle.WaitAll(myWaiter,10000))//,true))
+                               break;
+                       if(myHelper.Error == true || myHelper2.Error == true)
+                               break;
+               }
+               Test.Eval(!(myHelper.Error && myHelper2.Error));
+       }
+
+
+       
+}
+
+public class Test
+{
+       public static int nThreads = 50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<double>.EnterExitTest<int>();
+               Gen<string>.EnterExitTest<int>();
+               Gen<object>.EnterExitTest<int>();
+               Gen<Guid>.EnterExitTest<int>();
+               Gen<RefX1<int>>.EnterExitTest<int>();
+               Gen<RefX1<string>>.EnterExitTest<int>();
+               Gen<ValX1<int>>.EnterExitTest<int>();
+               Gen<ValX1<string>>.EnterExitTest<int>();
+               
+               Gen<int>.EnterExitTest<double>();       
+               Gen<string>.EnterExitTest<double>();
+               Gen<object>.EnterExitTest<double>();
+               Gen<Guid>.EnterExitTest<double>();
+               Gen<RefX1<int>>.EnterExitTest<double>();
+               Gen<RefX1<string>>.EnterExitTest<double>();
+               Gen<ValX1<int>>.EnterExitTest<double>();
+               Gen<ValX1<string>>.EnterExitTest<double>();
+
+               Gen<int>.EnterExitTest<string>();       
+               Gen<double>.EnterExitTest<string>();
+               Gen<object>.EnterExitTest<string>();
+               Gen<Guid>.EnterExitTest<string>();
+               Gen<RefX1<int>>.EnterExitTest<string>();
+               Gen<RefX1<string>>.EnterExitTest<string>();
+               Gen<ValX1<int>>.EnterExitTest<string>();
+               Gen<ValX1<string>>.EnterExitTest<string>();
+
+               Gen<int>.EnterExitTest<object>();       
+               Gen<double>.EnterExitTest<object>();
+               Gen<string>.EnterExitTest<object>();
+               Gen<Guid>.EnterExitTest<object>();
+               Gen<RefX1<int>>.EnterExitTest<object>();
+               Gen<RefX1<string>>.EnterExitTest<object>();
+               Gen<ValX1<int>>.EnterExitTest<object>();
+               Gen<ValX1<string>>.EnterExitTest<object>();
+
+               Gen<int>.EnterExitTest<Guid>(); 
+               Gen<double>.EnterExitTest<Guid>();
+               Gen<string>.EnterExitTest<Guid>();
+               Gen<object>.EnterExitTest<Guid>();
+               Gen<RefX1<int>>.EnterExitTest<Guid>();
+               Gen<RefX1<string>>.EnterExitTest<Guid>();
+               Gen<ValX1<int>>.EnterExitTest<Guid>();
+               Gen<ValX1<string>>.EnterExitTest<Guid>();
+
+               Gen<int>.EnterExitTest<RefX1<int>>();   
+               Gen<double>.EnterExitTest<RefX1<int>>();
+               Gen<string>.EnterExitTest<RefX1<int>>();
+               Gen<object>.EnterExitTest<RefX1<int>>();
+               Gen<Guid>.EnterExitTest<RefX1<int>>();
+               Gen<RefX1<string>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); 
+
+               Gen<int>.EnterExitTest<RefX1<string>>();        
+               Gen<double>.EnterExitTest<RefX1<string>>();
+               Gen<string>.EnterExitTest<RefX1<string>>();
+               Gen<object>.EnterExitTest<RefX1<string>>();
+               Gen<Guid>.EnterExitTest<RefX1<string>>();
+               Gen<RefX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<string>>();
+
+               Gen<int>.EnterExitTest<ValX1<int>>();   
+               Gen<double>.EnterExitTest<ValX1<int>>();
+               Gen<string>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<int>>();
+               Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+
+               Gen<int>.EnterExitTest<ValX1<string>>();        //offending line
+               Gen<double>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<string>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit12.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit12.csproj
new file mode 100644 (file)
index 0000000..8b03381
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit12.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit13.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit13.cs
new file mode 100644 (file)
index 0000000..e981bf5
--- /dev/null
@@ -0,0 +1,98 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+struct Gen<T> 
+{
+       public static object staticLock;
+       
+       public static void EnterExitTest()
+       {
+               staticLock = new object();
+               object monitor = staticLock;
+
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads];
+               // for(int i=0;i<consumer.Length;i++){
+               //      consumer[i] = new MonitorDelegate(myHelper.Consumer);
+               //      consumer[i].BeginInvoke(staticLock,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(staticLock);
+                       });
+               }
+
+               for(int i=0;i<6;i++){
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }
+}
+
+public class Test
+{
+       public static int nThreads = 50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.EnterExitTest();       
+               Gen<double>.EnterExitTest();
+               Gen<string>.EnterExitTest();
+               Gen<object>.EnterExitTest();
+               Gen<Guid>.EnterExitTest();
+
+               Gen<int[]>.EnterExitTest();
+               Gen<double[,]>.EnterExitTest();
+               Gen<string[][][]>.EnterExitTest();
+               Gen<object[,,,]>.EnterExitTest();
+               Gen<Guid[][,,,][]>.EnterExitTest();
+
+               Gen<RefX1<int>[]>.EnterExitTest();
+               Gen<RefX1<double>[,]>.EnterExitTest();
+               Gen<RefX1<string>[][][]>.EnterExitTest();
+               Gen<RefX1<object>[,,,]>.EnterExitTest();
+               Gen<RefX1<Guid>[][,,,][]>.EnterExitTest();
+
+               Gen<ValX1<int>[]>.EnterExitTest();
+               Gen<ValX1<double>[,]>.EnterExitTest();
+               Gen<ValX1<string>[][][]>.EnterExitTest();
+               Gen<ValX1<object>[,,,]>.EnterExitTest();
+               Gen<ValX1<Guid>[][,,,][]>.EnterExitTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit13.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit13.csproj
new file mode 100644 (file)
index 0000000..11ac732
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit13.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit14.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit14.cs
new file mode 100644 (file)
index 0000000..6bc0a8f
--- /dev/null
@@ -0,0 +1,175 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+struct Gen<T> 
+{
+       public static object staticLock;
+       public static void EnterExitTest<U>()
+       {
+               
+               Gen<T>.staticLock = new object();
+               Gen<U>.staticLock = new object();
+
+               object monitorT = Gen<T>.staticLock;
+               object monitorU = Gen<U>.staticLock;
+
+               if(monitorU.Equals(monitorT))
+                       throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG");
+                               
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               TestHelper myHelper2 = new TestHelper(Test.nThreads);
+               WaitHandle[] myWaiter = new WaitHandle[2];
+               myWaiter[0] = myHelper.m_Event;
+               myWaiter[1] = myHelper2.m_Event;
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null);
+               //      new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null);
+               // }
+
+               for(int i=0; i<Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitorT);
+                       });
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper2.Consumer(monitorU);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {       
+                       if(WaitHandle.WaitAll(myWaiter,10000))//,true))
+                               break;
+                       if(myHelper.Error == true || myHelper2.Error == true)
+                               break;
+               }
+               Test.Eval(!(myHelper.Error && myHelper2.Error));
+       }
+
+
+       
+}
+
+public class Test
+{
+       public static int nThreads = 50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<double>.EnterExitTest<int>();
+               Gen<string>.EnterExitTest<int>();
+               Gen<object>.EnterExitTest<int>();
+               Gen<Guid>.EnterExitTest<int>();
+               Gen<RefX1<int>>.EnterExitTest<int>();
+               Gen<RefX1<string>>.EnterExitTest<int>();
+               Gen<ValX1<int>>.EnterExitTest<int>();
+               Gen<ValX1<string>>.EnterExitTest<int>();
+               
+               Gen<int>.EnterExitTest<double>();       
+               Gen<string>.EnterExitTest<double>();
+               Gen<object>.EnterExitTest<double>();
+               Gen<Guid>.EnterExitTest<double>();
+               Gen<RefX1<int>>.EnterExitTest<double>();
+               Gen<RefX1<string>>.EnterExitTest<double>();
+               Gen<ValX1<int>>.EnterExitTest<double>();
+               Gen<ValX1<string>>.EnterExitTest<double>();
+
+               Gen<int>.EnterExitTest<string>();       
+               Gen<double>.EnterExitTest<string>();
+               Gen<object>.EnterExitTest<string>();
+               Gen<Guid>.EnterExitTest<string>();
+               Gen<RefX1<int>>.EnterExitTest<string>();
+               Gen<RefX1<string>>.EnterExitTest<string>();
+               Gen<ValX1<int>>.EnterExitTest<string>();
+               Gen<ValX1<string>>.EnterExitTest<string>();
+
+               Gen<int>.EnterExitTest<object>();       
+               Gen<double>.EnterExitTest<object>();
+               Gen<string>.EnterExitTest<object>();
+               Gen<Guid>.EnterExitTest<object>();
+               Gen<RefX1<int>>.EnterExitTest<object>();
+               Gen<RefX1<string>>.EnterExitTest<object>();
+               Gen<ValX1<int>>.EnterExitTest<object>();
+               Gen<ValX1<string>>.EnterExitTest<object>();
+
+               Gen<int>.EnterExitTest<Guid>(); 
+               Gen<double>.EnterExitTest<Guid>();
+               Gen<string>.EnterExitTest<Guid>();
+               Gen<object>.EnterExitTest<Guid>();
+               Gen<RefX1<int>>.EnterExitTest<Guid>();
+               Gen<RefX1<string>>.EnterExitTest<Guid>();
+               Gen<ValX1<int>>.EnterExitTest<Guid>();
+               Gen<ValX1<string>>.EnterExitTest<Guid>();
+
+               Gen<int>.EnterExitTest<RefX1<int>>();   
+               Gen<double>.EnterExitTest<RefX1<int>>();
+               Gen<string>.EnterExitTest<RefX1<int>>();
+               Gen<object>.EnterExitTest<RefX1<int>>();
+               Gen<Guid>.EnterExitTest<RefX1<int>>();
+               Gen<RefX1<string>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<int>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); 
+
+               Gen<int>.EnterExitTest<RefX1<string>>();        
+               Gen<double>.EnterExitTest<RefX1<string>>();
+               Gen<string>.EnterExitTest<RefX1<string>>();
+               Gen<object>.EnterExitTest<RefX1<string>>();
+               Gen<Guid>.EnterExitTest<RefX1<string>>();
+               Gen<RefX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<int>>.EnterExitTest<RefX1<string>>();
+               Gen<ValX1<string>>.EnterExitTest<RefX1<string>>();
+
+               Gen<int>.EnterExitTest<ValX1<int>>();   
+               Gen<double>.EnterExitTest<ValX1<int>>();
+               Gen<string>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<int>>();
+               Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+               Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line
+
+               Gen<int>.EnterExitTest<ValX1<string>>();        //offending line
+               Gen<double>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<string>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<object>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line
+               Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line
+               
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit14.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit14.csproj
new file mode 100644 (file)
index 0000000..6dcc34f
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit14.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit15.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit15.cs
new file mode 100644 (file)
index 0000000..41f9137
--- /dev/null
@@ -0,0 +1,93 @@
+using System;
+using System.Threading;
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+struct Gen<T> 
+{
+       public static void EnterExitTest()
+       {
+               Gen<T> monitor = new Gen<T>();          
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads];
+               // for(int i=0;i<Test.nThreads;i++)
+               // {
+               //      consumer[i] = new MonitorDelegate(myHelper.Consumer);
+               //      consumer[i].BeginInvoke(monitor,null,null);
+               // }
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.Consumer(monitor);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }       
+}
+
+public class Test
+{
+       public static int nThreads = 10;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.EnterExitTest();       
+               Gen<double>.EnterExitTest();
+               Gen<string>.EnterExitTest();
+               Gen<object>.EnterExitTest();
+               Gen<Guid>.EnterExitTest();
+
+               Gen<int[]>.EnterExitTest();
+               Gen<double[,]>.EnterExitTest();
+               Gen<string[][][]>.EnterExitTest();
+               Gen<object[,,,]>.EnterExitTest();
+               Gen<Guid[][,,,][]>.EnterExitTest();
+
+               Gen<RefX1<int>[]>.EnterExitTest();
+               Gen<RefX1<double>[,]>.EnterExitTest();
+               Gen<RefX1<string>[][][]>.EnterExitTest();
+               Gen<RefX1<object>[,,,]>.EnterExitTest();
+               Gen<RefX1<Guid>[][,,,][]>.EnterExitTest();
+
+               Gen<ValX1<int>[]>.EnterExitTest();
+               Gen<ValX1<double>[,]>.EnterExitTest();
+               Gen<ValX1<string>[][][]>.EnterExitTest();
+               Gen<ValX1<object>[,,,]>.EnterExitTest();
+               Gen<ValX1<Guid>[][,,,][]>.EnterExitTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit15.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit15.csproj
new file mode 100644 (file)
index 0000000..2558d0d
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="EnterExit15.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/MonitorHelper.cs b/tests/src/baseservices/threading/generics/Monitor/MonitorHelper.cs
new file mode 100644 (file)
index 0000000..1c14063
--- /dev/null
@@ -0,0 +1,86 @@
+using System;
+using System.Threading;
+delegate void MonitorDelegate(object monitor);
+delegate void MonitorDelegateTS(object monitor,int timeout);
+       
+class TestHelper
+{
+       private int m_iSharedData;
+       private int m_iRequestedEntries;
+       public ManualResetEvent m_Event;
+       public bool m_bError;
+
+       public bool Error
+       {               
+               set
+               {
+                       lock(typeof(TestHelper))
+                       {
+                               m_bError = value;
+                       }
+               }
+               get
+               {
+                       lock(typeof(TestHelper))
+                       {
+                               return m_bError;
+                       }
+               }
+       }
+
+       public TestHelper(int num)
+       {
+               m_Event = new ManualResetEvent(false);
+               m_iSharedData = 0;
+               m_iRequestedEntries = num;
+               m_bError = false;
+       }
+       
+       public void DoWork()
+       {
+               int snapshot = m_iSharedData;
+               Thread.Sleep(5);
+#if (DEBUG)
+               Console.WriteLine("Entering Monitor: " + m_iSharedData);
+#endif
+               m_iSharedData++;
+               Thread.Sleep(1);
+               if(m_iSharedData != snapshot + 1)
+               {
+                       Error = true;
+                       Console.WriteLine("Failure!!!");
+               }
+#if (DEBUG)
+               Console.WriteLine("Leaving Monitor: " + m_iSharedData);        
+#endif
+               if(m_iSharedData == m_iRequestedEntries)
+                       m_Event.Set();
+       }       
+       public void Consumer(object monitor)
+       {
+               lock(monitor)
+               {
+                       DoWork();
+               }       
+       }
+       public void ConsumerTryEnter(object monitor,int timeout)
+       {
+               try
+               {
+                       bool tookLock = false;
+                       
+                       Monitor.TryEnter(monitor,timeout, ref tookLock);
+
+                       while(!tookLock) {                              
+                               Thread.Sleep(0);
+                               Monitor.TryEnter(monitor,timeout, ref tookLock);
+                       }
+
+                       DoWork();
+               }
+               finally
+               {
+                       Monitor.Exit(monitor);
+               }
+       }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter01.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter01.cs
new file mode 100644 (file)
index 0000000..6645228
--- /dev/null
@@ -0,0 +1,95 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+class Gen<T> 
+{
+       public static void TryEnterTest()
+       {
+               // Gen<T> inst = new Gen<T>();
+               Type monitor = typeof(Gen<T>);
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // MonitorDelegateTS[] consumer = new MonitorDelegateTS[Test.nThreads];
+               // for(int i=0;i<consumer.Length;i++){
+                       // consumer[i] = new MonitorDelegateTS(myHelper.ConsumerTryEnter);
+                       // consumer[i].BeginInvoke(monitor,100,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.ConsumerTryEnter(monitor, 100);
+                       });
+               }
+
+               for(int i=0;i<6;i++){
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }       
+}
+
+public class Test
+{
+       public static int nThreads = 25;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.TryEnterTest();        
+               Gen<double>.TryEnterTest();
+               Gen<string>.TryEnterTest();
+               Gen<object>.TryEnterTest();
+               Gen<Guid>.TryEnterTest();
+
+               Gen<int[]>.TryEnterTest();
+               Gen<double[,]>.TryEnterTest();
+               Gen<string[][][]>.TryEnterTest();
+               Gen<object[,,,]>.TryEnterTest();
+               Gen<Guid[][,,,][]>.TryEnterTest();
+
+               Gen<RefX1<int>[]>.TryEnterTest();
+               Gen<RefX1<double>[,]>.TryEnterTest();
+               Gen<RefX1<string>[][][]>.TryEnterTest();
+               Gen<RefX1<object>[,,,]>.TryEnterTest();
+               Gen<RefX1<Guid>[][,,,][]>.TryEnterTest();
+
+               Gen<ValX1<int>[]>.TryEnterTest();
+               Gen<ValX1<double>[,]>.TryEnterTest();
+               Gen<ValX1<string>[][][]>.TryEnterTest();
+               Gen<ValX1<object>[,,,]>.TryEnterTest();
+               Gen<ValX1<Guid>[][,,,][]>.TryEnterTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter01.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter01.csproj
new file mode 100644 (file)
index 0000000..0bf7a62
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="TryEnter01.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter03.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter03.cs
new file mode 100644 (file)
index 0000000..f4ba633
--- /dev/null
@@ -0,0 +1,174 @@
+using System;
+using System.Threading;
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+class Gen<T> 
+{
+
+       public static void TryEnterTest<U>(bool TisU)
+       {
+               Type monitorT = typeof(Gen<T>);
+               Type monitorU = typeof(Gen<U>);
+
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               TestHelper myHelper2 = new TestHelper(Test.nThreads);
+
+               WaitHandle[] myWaiter = new WaitHandle[2];
+               myWaiter[0] = myHelper.m_Event;
+               myWaiter[1] = myHelper2.m_Event;
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       // new MonitorDelegateTS(myHelper.ConsumerTryEnter).BeginInvoke(monitorT,100,null,null);
+                       // new MonitorDelegateTS(myHelper2.ConsumerTryEnter).BeginInvoke(monitorU,100,null,null);
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.ConsumerTryEnter(monitorT, 100);
+                       });
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper2.ConsumerTryEnter(monitorU, 100);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {       
+                       if(WaitHandle.WaitAll(myWaiter,10000))//,true))
+                               break;
+                       if(myHelper.Error == true || myHelper2.Error == true)
+                               break;
+               }
+               Test.Eval(!(myHelper.Error && myHelper2.Error));
+               
+       }
+
+
+       
+}
+
+public class Test
+{
+       public static int nThreads = 25;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.TryEnterTest<int>(true);       
+               Gen<double>.TryEnterTest<int>(false);
+               Gen<string>.TryEnterTest<int>(false);
+               Gen<object>.TryEnterTest<int>(false);
+               Gen<Guid>.TryEnterTest<int>(false);
+               Gen<RefX1<int>>.TryEnterTest<int>(false);
+               Gen<RefX1<string>>.TryEnterTest<int>(false);
+               Gen<ValX1<int>>.TryEnterTest<int>(false);
+               Gen<ValX1<string>>.TryEnterTest<int>(false);
+               
+               Gen<int>.TryEnterTest<double>(false);   
+               Gen<double>.TryEnterTest<double>(true);
+               Gen<string>.TryEnterTest<double>(false);
+               Gen<object>.TryEnterTest<double>(false);
+               Gen<Guid>.TryEnterTest<double>(false);
+               Gen<RefX1<int>>.TryEnterTest<double>(false);
+               Gen<RefX1<string>>.TryEnterTest<double>(false);
+               Gen<ValX1<int>>.TryEnterTest<double>(false);
+               Gen<ValX1<string>>.TryEnterTest<double>(false);
+
+               Gen<int>.TryEnterTest<string>(false);   
+               Gen<double>.TryEnterTest<string>(false);
+               Gen<string>.TryEnterTest<string>(true);
+               Gen<object>.TryEnterTest<string>(false);
+               Gen<Guid>.TryEnterTest<string>(false);
+               Gen<RefX1<int>>.TryEnterTest<string>(false);
+               Gen<RefX1<string>>.TryEnterTest<string>(false);
+               Gen<ValX1<int>>.TryEnterTest<string>(false);
+               Gen<ValX1<string>>.TryEnterTest<string>(false);
+
+               Gen<int>.TryEnterTest<object>(false);   
+               Gen<double>.TryEnterTest<object>(false);
+               Gen<string>.TryEnterTest<object>(false);
+               Gen<object>.TryEnterTest<object>(true);
+               Gen<Guid>.TryEnterTest<object>(false);
+               Gen<RefX1<int>>.TryEnterTest<object>(false);
+               Gen<RefX1<string>>.TryEnterTest<object>(false);
+               Gen<ValX1<int>>.TryEnterTest<object>(false);
+               Gen<ValX1<string>>.TryEnterTest<object>(false);
+
+               Gen<int>.TryEnterTest<Guid>(false);     
+               Gen<double>.TryEnterTest<Guid>(false);
+               Gen<string>.TryEnterTest<Guid>(false);
+               Gen<object>.TryEnterTest<Guid>(false);
+               Gen<Guid>.TryEnterTest<Guid>(true);
+               Gen<RefX1<int>>.TryEnterTest<Guid>(false);
+               Gen<RefX1<string>>.TryEnterTest<Guid>(false);
+               Gen<ValX1<int>>.TryEnterTest<Guid>(false);
+               Gen<ValX1<string>>.TryEnterTest<Guid>(false);
+
+               Gen<int>.TryEnterTest<RefX1<int>>(false);       
+               Gen<double>.TryEnterTest<RefX1<int>>(false);
+               Gen<string>.TryEnterTest<RefX1<int>>(false);
+               Gen<object>.TryEnterTest<RefX1<int>>(false);
+               Gen<Guid>.TryEnterTest<RefX1<int>>(false);
+               Gen<RefX1<int>>.TryEnterTest<RefX1<int>>(true);
+               Gen<RefX1<string>>.TryEnterTest<RefX1<int>>(false);
+               Gen<ValX1<int>>.TryEnterTest<RefX1<int>>(false);
+               Gen<ValX1<string>>.TryEnterTest<RefX1<int>>(false);     
+
+               Gen<int>.TryEnterTest<RefX1<string>>(false);    
+               Gen<double>.TryEnterTest<RefX1<string>>(false);
+               Gen<string>.TryEnterTest<RefX1<string>>(false);
+               Gen<object>.TryEnterTest<RefX1<string>>(false);
+               Gen<Guid>.TryEnterTest<RefX1<string>>(false);
+               Gen<RefX1<int>>.TryEnterTest<RefX1<string>>(false);
+               Gen<RefX1<string>>.TryEnterTest<RefX1<string>>(true);
+               Gen<ValX1<int>>.TryEnterTest<RefX1<string>>(false);
+               Gen<ValX1<string>>.TryEnterTest<RefX1<string>>(false);
+
+               Gen<int>.TryEnterTest<ValX1<int>>(false);       
+               Gen<double>.TryEnterTest<ValX1<int>>(false);
+               Gen<string>.TryEnterTest<ValX1<int>>(false); //offending line
+               Gen<object>.TryEnterTest<ValX1<int>>(false); //offending line
+               Gen<Guid>.TryEnterTest<ValX1<int>>(false);
+               Gen<RefX1<int>>.TryEnterTest<ValX1<int>>(false); //offending line
+               Gen<RefX1<string>>.TryEnterTest<ValX1<int>>(false); //offending line
+               Gen<ValX1<int>>.TryEnterTest<ValX1<int>>(true);
+               Gen<ValX1<string>>.TryEnterTest<ValX1<int>>(false); //offending line
+
+               Gen<int>.TryEnterTest<ValX1<string>>(false);    //offending line
+               Gen<double>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<string>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<object>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<Guid>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<RefX1<int>>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<RefX1<string>>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<ValX1<int>>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<ValX1<string>>.TryEnterTest<ValX1<string>>(true); //offending line
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter03.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter03.csproj
new file mode 100644 (file)
index 0000000..f5d4824
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="TryEnter03.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter04.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter04.cs
new file mode 100644 (file)
index 0000000..5c65fe6
--- /dev/null
@@ -0,0 +1,96 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+struct Gen<T> 
+{
+       public static void TryEnterTest()
+       {
+// #pragma warning disable 219
+//             Gen<T> inst = new Gen<T>();
+// #pragma warning restore
+               Type monitor = typeof(Gen<T>);
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // MonitorDelegateTS[] consumer = new MonitorDelegateTS[Test.nThreads];
+               // for(int i=0;i<consumer.Length;i++){
+               //      consumer[i] = new MonitorDelegateTS(myHelper.ConsumerTryEnter);
+               //      consumer[i].BeginInvoke(monitor,100,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.ConsumerTryEnter(monitor, 100);
+                       });
+               }
+
+               for(int i=0;i<6;i++){
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }       
+}
+
+public class Test
+{
+       public static int nThreads = 25;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.TryEnterTest();        
+               /*Gen<double>.TryEnterTest();
+               Gen<string>.TryEnterTest();
+               Gen<object>.TryEnterTest();
+               Gen<Guid>.TryEnterTest();
+
+               Gen<int[]>.TryEnterTest();
+               Gen<double[,]>.TryEnterTest();
+               Gen<string[][][]>.TryEnterTest();
+               Gen<object[,,,]>.TryEnterTest();
+               Gen<Guid[][,,,][]>.TryEnterTest();
+
+               Gen<RefX1<int>[]>.TryEnterTest();
+               Gen<RefX1<double>[,]>.TryEnterTest();
+               Gen<RefX1<string>[][][]>.TryEnterTest();
+               Gen<RefX1<object>[,,,]>.TryEnterTest();
+               Gen<RefX1<Guid>[][,,,][]>.TryEnterTest();
+
+               Gen<ValX1<int>[]>.TryEnterTest();
+               Gen<ValX1<double>[,]>.TryEnterTest();
+               Gen<ValX1<string>[][][]>.TryEnterTest();
+               Gen<ValX1<object>[,,,]>.TryEnterTest();
+               Gen<ValX1<Guid>[][,,,][]>.TryEnterTest();*/
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter04.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter04.csproj
new file mode 100644 (file)
index 0000000..3063161
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="TryEnter04.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter05.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter05.cs
new file mode 100644 (file)
index 0000000..d9a5f41
--- /dev/null
@@ -0,0 +1,96 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+struct Gen<T> 
+{
+       delegate void StructDelegateTS(object monitor,int timeout);
+
+       public static void TryEnterTest()
+       {
+               Type monitor = typeof(Gen<T>);
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               // StructDelegateTS[] consumer = new StructDelegateTS[Test.nThreads];
+               // for(int i=0;i<consumer.Length;i++){
+               //      consumer[i] = new StructDelegateTS(myHelper.ConsumerTryEnter);
+               //      consumer[i].BeginInvoke(monitor,100,null,null);
+               // }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.ConsumerTryEnter(monitor, 100);
+                       });
+               }
+
+               for(int i=0;i<6;i++){
+                       if(myHelper.m_Event.WaitOne(10000))//,true))
+                               break;
+                       if(myHelper.Error == true)
+                               break;
+               }
+               Test.Eval(!myHelper.Error);
+       }
+}
+
+public class Test
+{
+       public static int nThreads = 25;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.TryEnterTest();        
+               Gen<double>.TryEnterTest();
+               Gen<string>.TryEnterTest();
+               Gen<object>.TryEnterTest();
+               Gen<Guid>.TryEnterTest();
+
+               Gen<int[]>.TryEnterTest();
+               Gen<double[,]>.TryEnterTest();
+               Gen<string[][][]>.TryEnterTest();
+               Gen<object[,,,]>.TryEnterTest();
+               Gen<Guid[][,,,][]>.TryEnterTest();
+
+               Gen<RefX1<int>[]>.TryEnterTest();
+               Gen<RefX1<double>[,]>.TryEnterTest();
+               Gen<RefX1<string>[][][]>.TryEnterTest();
+               Gen<RefX1<object>[,,,]>.TryEnterTest();
+               Gen<RefX1<Guid>[][,,,][]>.TryEnterTest();
+
+               Gen<ValX1<int>[]>.TryEnterTest();
+               Gen<ValX1<double>[,]>.TryEnterTest();
+               Gen<ValX1<string>[][][]>.TryEnterTest();
+               Gen<ValX1<object>[,,,]>.TryEnterTest();
+               Gen<ValX1<Guid>[][,,,][]>.TryEnterTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter05.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter05.csproj
new file mode 100644 (file)
index 0000000..7fe96de
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="TryEnter05.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter06.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter06.cs
new file mode 100644 (file)
index 0000000..b591fb1
--- /dev/null
@@ -0,0 +1,174 @@
+using System;
+using System.Threading;
+
+
+public struct ValX1<T> {}
+public class RefX1<T> {}
+
+struct Gen<T> 
+{
+
+       public static void TryEnterTest<U>(bool TisU)
+       {
+               Type monitorT = typeof(Gen<T>);
+               Type monitorU = typeof(Gen<U>);
+
+               TestHelper myHelper = new TestHelper(Test.nThreads);
+               TestHelper myHelper2 = new TestHelper(Test.nThreads);
+               WaitHandle[] myWaiter = new WaitHandle[2];
+               myWaiter[0] = myHelper.m_Event;
+               myWaiter[1] = myHelper2.m_Event;
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       //      new MonitorDelegateTS(myHelper.ConsumerTryEnter).BeginInvoke(monitorT,100,null,null);
+                       //      new MonitorDelegateTS(myHelper2.ConsumerTryEnter).BeginInvoke(monitorU,100,null,null);
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper.ConsumerTryEnter(monitorT, 100);
+                       });
+
+                       ThreadPool.QueueUserWorkItem(state =>
+                       {
+                               myHelper2.ConsumerTryEnter(monitorU, 100);
+                       });
+               }
+
+               for(int i=0;i<6;i++)
+               {       
+                       if(WaitHandle.WaitAll(myWaiter,10000))//,true))
+                               break;
+                       if(myHelper.Error == true || myHelper2.Error == true)
+                               break;
+               }
+               Test.Eval(!(myHelper.Error && myHelper2.Error));
+               
+       }
+
+
+       
+}
+
+public class Test
+{
+       public static int nThreads = 25;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.TryEnterTest<int>(true);       
+               Gen<double>.TryEnterTest<int>(false);
+               Gen<string>.TryEnterTest<int>(false);
+               Gen<object>.TryEnterTest<int>(false);
+               Gen<Guid>.TryEnterTest<int>(false);
+               Gen<RefX1<int>>.TryEnterTest<int>(false);
+               Gen<RefX1<string>>.TryEnterTest<int>(false);
+               Gen<ValX1<int>>.TryEnterTest<int>(false);
+               Gen<ValX1<string>>.TryEnterTest<int>(false);
+               
+               Gen<int>.TryEnterTest<double>(false);   
+               Gen<double>.TryEnterTest<double>(true);
+               Gen<string>.TryEnterTest<double>(false);
+               Gen<object>.TryEnterTest<double>(false);
+               Gen<Guid>.TryEnterTest<double>(false);
+               Gen<RefX1<int>>.TryEnterTest<double>(false);
+               Gen<RefX1<string>>.TryEnterTest<double>(false);
+               Gen<ValX1<int>>.TryEnterTest<double>(false);
+               Gen<ValX1<string>>.TryEnterTest<double>(false);
+
+               Gen<int>.TryEnterTest<string>(false);   
+               Gen<double>.TryEnterTest<string>(false);
+               Gen<string>.TryEnterTest<string>(true);
+               Gen<object>.TryEnterTest<string>(false);
+               Gen<Guid>.TryEnterTest<string>(false);
+               Gen<RefX1<int>>.TryEnterTest<string>(false);
+               Gen<RefX1<string>>.TryEnterTest<string>(false);
+               Gen<ValX1<int>>.TryEnterTest<string>(false);
+               Gen<ValX1<string>>.TryEnterTest<string>(false);
+
+               Gen<int>.TryEnterTest<object>(false);   
+               Gen<double>.TryEnterTest<object>(false);
+               Gen<string>.TryEnterTest<object>(false);
+               Gen<object>.TryEnterTest<object>(true);
+               Gen<Guid>.TryEnterTest<object>(false);
+               Gen<RefX1<int>>.TryEnterTest<object>(false);
+               Gen<RefX1<string>>.TryEnterTest<object>(false);
+               Gen<ValX1<int>>.TryEnterTest<object>(false);
+               Gen<ValX1<string>>.TryEnterTest<object>(false);
+
+               Gen<int>.TryEnterTest<Guid>(false);     
+               Gen<double>.TryEnterTest<Guid>(false);
+               Gen<string>.TryEnterTest<Guid>(false);
+               Gen<object>.TryEnterTest<Guid>(false);
+               Gen<Guid>.TryEnterTest<Guid>(true);
+               Gen<RefX1<int>>.TryEnterTest<Guid>(false);
+               Gen<RefX1<string>>.TryEnterTest<Guid>(false);
+               Gen<ValX1<int>>.TryEnterTest<Guid>(false);
+               Gen<ValX1<string>>.TryEnterTest<Guid>(false);
+
+               Gen<int>.TryEnterTest<RefX1<int>>(false);       
+               Gen<double>.TryEnterTest<RefX1<int>>(false);
+               Gen<string>.TryEnterTest<RefX1<int>>(false);
+               Gen<object>.TryEnterTest<RefX1<int>>(false);
+               Gen<Guid>.TryEnterTest<RefX1<int>>(false);
+               Gen<RefX1<int>>.TryEnterTest<RefX1<int>>(true);
+               Gen<RefX1<string>>.TryEnterTest<RefX1<int>>(false);
+               Gen<ValX1<int>>.TryEnterTest<RefX1<int>>(false);
+               Gen<ValX1<string>>.TryEnterTest<RefX1<int>>(false);     
+
+               Gen<int>.TryEnterTest<RefX1<string>>(false);    
+               Gen<double>.TryEnterTest<RefX1<string>>(false);
+               Gen<string>.TryEnterTest<RefX1<string>>(false);
+               Gen<object>.TryEnterTest<RefX1<string>>(false);
+               Gen<Guid>.TryEnterTest<RefX1<string>>(false);
+               Gen<RefX1<int>>.TryEnterTest<RefX1<string>>(false);
+               Gen<RefX1<string>>.TryEnterTest<RefX1<string>>(true);
+               Gen<ValX1<int>>.TryEnterTest<RefX1<string>>(false);
+               Gen<ValX1<string>>.TryEnterTest<RefX1<string>>(false);
+
+               Gen<int>.TryEnterTest<ValX1<int>>(false);       
+               Gen<double>.TryEnterTest<ValX1<int>>(false);
+               Gen<string>.TryEnterTest<ValX1<int>>(false); //offending line
+               Gen<object>.TryEnterTest<ValX1<int>>(false); //offending line
+               Gen<Guid>.TryEnterTest<ValX1<int>>(false);
+               Gen<RefX1<int>>.TryEnterTest<ValX1<int>>(false); //offending line
+               Gen<RefX1<string>>.TryEnterTest<ValX1<int>>(false); //offending line
+               Gen<ValX1<int>>.TryEnterTest<ValX1<int>>(true);
+               Gen<ValX1<string>>.TryEnterTest<ValX1<int>>(false); //offending line
+
+               Gen<int>.TryEnterTest<ValX1<string>>(false);    //offending line
+               Gen<double>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<string>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<object>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<Guid>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<RefX1<int>>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<RefX1<string>>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<ValX1<int>>.TryEnterTest<ValX1<string>>(false); //offending line
+               Gen<ValX1<string>>.TryEnterTest<ValX1<string>>(true); //offending line
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter06.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter06.csproj
new file mode 100644 (file)
index 0000000..f018ee2
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="TryEnter06.cs" />
+    <Compile Include="MonitorHelper.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/Monitor/project.json b/tests/src/baseservices/threading/generics/Monitor/project.json
new file mode 100644 (file)
index 0000000..c14efc6
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/project.json b/tests/src/baseservices/threading/generics/TimerCallback/project.json
new file mode 100644 (file)
index 0000000..864cd20
--- /dev/null
@@ -0,0 +1,35 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.Timer": "4.0.0-rc3-23823",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread01.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread01.cs
new file mode 100644 (file)
index 0000000..635d0bd
--- /dev/null
@@ -0,0 +1,81 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               Gen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0; // was long
+       public static int period = 2; // was long
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread01.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread01.csproj
new file mode 100644 (file)
index 0000000..7235f93
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread01.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread02.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread02.cs
new file mode 100644 (file)
index 0000000..876ff18
--- /dev/null
@@ -0,0 +1,81 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public virtual void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               Gen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread02.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread02.csproj
new file mode 100644 (file)
index 0000000..7d8a014
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread02.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread03.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread03.cs
new file mode 100644 (file)
index 0000000..b8f69d4
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+class Gen 
+{
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               Gen obj = new Gen();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread03.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread03.csproj
new file mode 100644 (file)
index 0000000..198813f
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread03.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread04.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread04.cs
new file mode 100644 (file)
index 0000000..f641e5c
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+class Gen 
+{
+       public virtual void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               Gen obj = new Gen();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread04.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread04.csproj
new file mode 100644 (file)
index 0000000..8480ccb
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread04.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread05.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread05.cs
new file mode 100644 (file)
index 0000000..f3f69b5
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               Gen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int Xcounter = 0;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread05.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread05.csproj
new file mode 100644 (file)
index 0000000..846cdcc
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread05.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread06.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread06.cs
new file mode 100644 (file)
index 0000000..d7723f5
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public virtual void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               Gen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int Xcounter = 0;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread06.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread06.csproj
new file mode 100644 (file)
index 0000000..655d5d5
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread06.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread07.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread07.cs
new file mode 100644 (file)
index 0000000..6bf78fb
--- /dev/null
@@ -0,0 +1,81 @@
+using System;
+using System.Threading;
+
+struct Gen<T> 
+{
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               Gen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread07.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread07.csproj
new file mode 100644 (file)
index 0000000..9368e18
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread07.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread08.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread08.cs
new file mode 100644 (file)
index 0000000..0a50caf
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+struct Gen 
+{
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               Gen obj = new Gen();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread08.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread08.csproj
new file mode 100644 (file)
index 0000000..52167e1
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread08.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread09.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread09.cs
new file mode 100644 (file)
index 0000000..d08101a
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+struct Gen<T> 
+{
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               Gen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int Xcounter = 0;
+       public static int counter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread09.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread09.csproj
new file mode 100644 (file)
index 0000000..4432725
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread09.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread10.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread10.cs
new file mode 100644 (file)
index 0000000..eb63125
--- /dev/null
@@ -0,0 +1,90 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+class Gen<T> : IGen<T>
+{
+       public T Dummy(T t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread10.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread10.csproj
new file mode 100644 (file)
index 0000000..221aee2
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread10.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread11.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread11.cs
new file mode 100644 (file)
index 0000000..06b6d05
--- /dev/null
@@ -0,0 +1,90 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+struct Gen<T> : IGen<T>
+{
+       public T Dummy(T t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread11.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread11.csproj
new file mode 100644 (file)
index 0000000..fd4dad1
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread11.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread12.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread12.cs
new file mode 100644 (file)
index 0000000..19bd8f6
--- /dev/null
@@ -0,0 +1,90 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+class Gen<T> : IGen<T>
+{
+       public T Dummy(T t) { return t; }
+
+       public virtual void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread12.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread12.csproj
new file mode 100644 (file)
index 0000000..36ac224
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread12.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread13.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread13.cs
new file mode 100644 (file)
index 0000000..4d74b4a
--- /dev/null
@@ -0,0 +1,216 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+class GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<int> obj = new GenInt();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<double> obj = new GenDouble();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<string> obj = new GenString();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<object> obj = new GenObject();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<Guid> obj = new GenGuid();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest();
+               GenDouble.ThreadPoolTest();
+               GenString.ThreadPoolTest();
+               GenObject.ThreadPoolTest(); 
+               GenGuid.ThreadPoolTest();       
+               
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread13.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread13.csproj
new file mode 100644 (file)
index 0000000..9712549
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread13.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread14.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread14.cs
new file mode 100644 (file)
index 0000000..2cfa565
--- /dev/null
@@ -0,0 +1,216 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+struct GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<int> obj = new GenInt();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<double> obj = new GenDouble();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<string> obj = new GenString();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<object> obj = new GenObject();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<Guid> obj = new GenGuid();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest();
+               GenDouble.ThreadPoolTest();
+               GenString.ThreadPoolTest();
+               GenObject.ThreadPoolTest(); 
+               GenGuid.ThreadPoolTest();       
+               
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread14.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread14.csproj
new file mode 100644 (file)
index 0000000..81496bf
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread14.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread15.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread15.cs
new file mode 100644 (file)
index 0000000..69aabce
--- /dev/null
@@ -0,0 +1,216 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+class GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public virtual void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<int> obj = new GenInt();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public virtual void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<double> obj = new GenDouble();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public virtual void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<string> obj = new GenString();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public virtual void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<object> obj = new GenObject();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public virtual void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<Guid> obj = new GenGuid();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest();
+               GenDouble.ThreadPoolTest();
+               GenString.ThreadPoolTest();
+               GenObject.ThreadPoolTest(); 
+               GenGuid.ThreadPoolTest();       
+               
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread15.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread15.csproj
new file mode 100644 (file)
index 0000000..63f07aa
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread15.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread16.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread16.cs
new file mode 100644 (file)
index 0000000..1eb2edd
--- /dev/null
@@ -0,0 +1,82 @@
+using System;
+using System.Threading;
+
+interface IGen
+{
+       void Target<U>(object p);
+}
+
+class Gen : IGen
+{
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen obj = new Gen();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread16.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread16.csproj
new file mode 100644 (file)
index 0000000..5a3858f
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread16.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread17.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread17.cs
new file mode 100644 (file)
index 0000000..ee59e1f
--- /dev/null
@@ -0,0 +1,82 @@
+using System;
+using System.Threading;
+
+interface IGen
+{
+       void Target<U>(object p);
+}
+
+struct Gen : IGen
+{
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen obj = new Gen();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread17.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread17.csproj
new file mode 100644 (file)
index 0000000..c6dfdc3
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread17.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread18.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread18.cs
new file mode 100644 (file)
index 0000000..652ea65
--- /dev/null
@@ -0,0 +1,82 @@
+using System;
+using System.Threading;
+
+interface IGen
+{
+       void Target<U>(object p);
+}
+
+class Gen : IGen
+{
+       public virtual void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen obj = new Gen();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread18.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread18.csproj
new file mode 100644 (file)
index 0000000..c3b4d62
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread18.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread19.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread19.cs
new file mode 100644 (file)
index 0000000..2e2455b
--- /dev/null
@@ -0,0 +1,86 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+class Gen<T> : IGen<T>
+{
+       public T Dummy(T t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread19.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread19.csproj
new file mode 100644 (file)
index 0000000..44e70db
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread19.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread20.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread20.cs
new file mode 100644 (file)
index 0000000..b812718
--- /dev/null
@@ -0,0 +1,86 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+struct Gen<T> : IGen<T>
+{
+       public T Dummy(T t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread20.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread20.csproj
new file mode 100644 (file)
index 0000000..362a53f
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread20.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread21.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread21.cs
new file mode 100644 (file)
index 0000000..a3a908d
--- /dev/null
@@ -0,0 +1,86 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+class Gen<T> : IGen<T>
+{
+       public T Dummy(T t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<T> obj = new Gen<T>();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread21.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread21.csproj
new file mode 100644 (file)
index 0000000..aeaaee7
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread21.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread22.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread22.cs
new file mode 100644 (file)
index 0000000..2491bc5
--- /dev/null
@@ -0,0 +1,240 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+class GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<int> obj = new GenInt();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<double> obj = new GenDouble();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<string> obj = new GenString();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<object> obj = new GenObject();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<Guid> obj = new GenGuid();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest<int>();
+               GenDouble.ThreadPoolTest<int>();
+               GenString.ThreadPoolTest<int>();
+               GenObject.ThreadPoolTest<int>(); 
+               GenGuid.ThreadPoolTest<int>(); 
+
+               GenInt.ThreadPoolTest<double>();
+               GenDouble.ThreadPoolTest<double>();
+               GenString.ThreadPoolTest<double>();
+               GenObject.ThreadPoolTest<double>(); 
+               GenGuid.ThreadPoolTest<double>(); 
+
+               GenInt.ThreadPoolTest<string>();
+               GenDouble.ThreadPoolTest<string>();
+               GenString.ThreadPoolTest<string>();
+               GenObject.ThreadPoolTest<string>(); 
+               GenGuid.ThreadPoolTest<string>(); 
+
+               GenInt.ThreadPoolTest<object>();
+               GenDouble.ThreadPoolTest<object>();
+               GenString.ThreadPoolTest<object>();
+               GenObject.ThreadPoolTest<object>(); 
+               GenGuid.ThreadPoolTest<object>(); 
+
+               GenInt.ThreadPoolTest<Guid>();
+               GenDouble.ThreadPoolTest<Guid>();
+               GenString.ThreadPoolTest<Guid>();
+               GenObject.ThreadPoolTest<Guid>(); 
+               GenGuid.ThreadPoolTest<Guid>(); 
+               
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread22.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread22.csproj
new file mode 100644 (file)
index 0000000..bdc60d5
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread22.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread23.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread23.cs
new file mode 100644 (file)
index 0000000..c89875c
--- /dev/null
@@ -0,0 +1,240 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+struct GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<int> obj = new GenInt();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<double> obj = new GenDouble();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<string> obj = new GenString();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<object> obj = new GenObject();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<Guid> obj = new GenGuid();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest<int>();
+               GenDouble.ThreadPoolTest<int>();
+               GenString.ThreadPoolTest<int>();
+               GenObject.ThreadPoolTest<int>(); 
+               GenGuid.ThreadPoolTest<int>(); 
+
+               GenInt.ThreadPoolTest<double>();
+               GenDouble.ThreadPoolTest<double>();
+               GenString.ThreadPoolTest<double>();
+               GenObject.ThreadPoolTest<double>(); 
+               GenGuid.ThreadPoolTest<double>(); 
+
+               GenInt.ThreadPoolTest<string>();
+               GenDouble.ThreadPoolTest<string>();
+               GenString.ThreadPoolTest<string>();
+               GenObject.ThreadPoolTest<string>(); 
+               GenGuid.ThreadPoolTest<string>(); 
+
+               GenInt.ThreadPoolTest<object>();
+               GenDouble.ThreadPoolTest<object>();
+               GenString.ThreadPoolTest<object>();
+               GenObject.ThreadPoolTest<object>(); 
+               GenGuid.ThreadPoolTest<object>(); 
+
+               GenInt.ThreadPoolTest<Guid>();
+               GenDouble.ThreadPoolTest<Guid>();
+               GenString.ThreadPoolTest<Guid>();
+               GenObject.ThreadPoolTest<Guid>(); 
+               GenGuid.ThreadPoolTest<Guid>(); 
+               
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread23.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread23.csproj
new file mode 100644 (file)
index 0000000..d67aaa5
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread23.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread24.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread24.cs
new file mode 100644 (file)
index 0000000..14b1651
--- /dev/null
@@ -0,0 +1,240 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+class GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<int> obj = new GenInt();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<double> obj = new GenDouble();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<string> obj = new GenString();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<object> obj = new GenObject();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+               
+               IGen<Guid> obj = new GenGuid();
+
+               TimerCallback tcb = new TimerCallback(obj.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest<int>();
+               GenDouble.ThreadPoolTest<int>();
+               GenString.ThreadPoolTest<int>();
+               GenObject.ThreadPoolTest<int>(); 
+               GenGuid.ThreadPoolTest<int>(); 
+
+               GenInt.ThreadPoolTest<double>();
+               GenDouble.ThreadPoolTest<double>();
+               GenString.ThreadPoolTest<double>();
+               GenObject.ThreadPoolTest<double>(); 
+               GenGuid.ThreadPoolTest<double>(); 
+
+               GenInt.ThreadPoolTest<string>();
+               GenDouble.ThreadPoolTest<string>();
+               GenString.ThreadPoolTest<string>();
+               GenObject.ThreadPoolTest<string>(); 
+               GenGuid.ThreadPoolTest<string>(); 
+
+               GenInt.ThreadPoolTest<object>();
+               GenDouble.ThreadPoolTest<object>();
+               GenString.ThreadPoolTest<object>();
+               GenObject.ThreadPoolTest<object>(); 
+               GenGuid.ThreadPoolTest<object>(); 
+
+               GenInt.ThreadPoolTest<Guid>();
+               GenDouble.ThreadPoolTest<Guid>();
+               GenString.ThreadPoolTest<Guid>();
+               GenObject.ThreadPoolTest<Guid>(); 
+               GenGuid.ThreadPoolTest<Guid>(); 
+               
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread24.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread24.csproj
new file mode 100644 (file)
index 0000000..ddb4ca4
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread24.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread25.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread25.cs
new file mode 100644 (file)
index 0000000..8e1b95e
--- /dev/null
@@ -0,0 +1,79 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public static void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+
+               TimerCallback tcb = new TimerCallback(Gen<T>.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread25.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread25.csproj
new file mode 100644 (file)
index 0000000..5ff4103
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread25.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread26.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread26.cs
new file mode 100644 (file)
index 0000000..48c9dee
--- /dev/null
@@ -0,0 +1,79 @@
+using System;
+using System.Threading;
+
+struct Gen<T> 
+{
+       public static void Target(object p)
+       {                       
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+
+               TimerCallback tcb = new TimerCallback(Gen<T>.Target);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread26.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread26.csproj
new file mode 100644 (file)
index 0000000..f05ac41
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread26.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread27.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread27.cs
new file mode 100644 (file)
index 0000000..32a6a12
--- /dev/null
@@ -0,0 +1,75 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public static void Target<U>(object p)
+       {                       
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+
+               TimerCallback tcb = new TimerCallback(Gen<T>.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread27.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread27.csproj
new file mode 100644 (file)
index 0000000..9fbe49c
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread27.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread28.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread28.cs
new file mode 100644 (file)
index 0000000..cfcd9f6
--- /dev/null
@@ -0,0 +1,75 @@
+using System;
+using System.Threading;
+
+struct Gen<T> 
+{
+       public static void Target<U>(object p)
+       {       
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());              
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+
+               TimerCallback tcb = new TimerCallback(Gen<T>.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread28.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread28.csproj
new file mode 100644 (file)
index 0000000..0b9be38
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread28.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread29.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread29.cs
new file mode 100644 (file)
index 0000000..c9724f3
--- /dev/null
@@ -0,0 +1,75 @@
+using System;
+using System.Threading;
+
+class Gen
+{
+       public static void Target<U>(object p)
+       {                       
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+
+               TimerCallback tcb = new TimerCallback(Gen.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread29.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread29.csproj
new file mode 100644 (file)
index 0000000..63c8e84
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread29.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread30.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread30.cs
new file mode 100644 (file)
index 0000000..babec5c
--- /dev/null
@@ -0,0 +1,75 @@
+using System;
+using System.Threading;
+
+struct Gen
+{
+       public static void Target<U>(object p)
+       {                       
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               if (Test.Xcounter>=Test.nThreads)
+               {
+                       ManualResetEvent evt = (ManualResetEvent) p;    
+                       evt.Set();
+               }
+               else
+               {
+                       Interlocked.Increment(ref Test.Xcounter);       
+               }
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent evt = new ManualResetEvent(false);             
+
+               TimerCallback tcb = new TimerCallback(Gen.Target<U>);
+               Timer timer = new Timer(tcb,evt,Test.delay,Test.period);
+       
+               evt.WaitOne();
+               timer.Dispose();
+               Test.Eval(Test.Xcounter>=Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 2;
+       public static int nThreads = 5;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread30.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread30.csproj
new file mode 100644 (file)
index 0000000..f5baa79
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread30.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.cs b/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.cs
new file mode 100644 (file)
index 0000000..ebd3852
--- /dev/null
@@ -0,0 +1,88 @@
+using System;
+using System.Threading;
+using System.Diagnostics;
+
+//namespace TimerCallbackTests ////////////// added this namesp
+
+class Gen<T> 
+{
+       public static Type objType;
+
+       public void Target(object p)
+       {                       
+               Interlocked.Increment(ref Test.Xcounter);
+               if (p.GetType() != objType)
+               {
+                       Test.result = false;
+                       Console.WriteLine("Expected parameter type: " + objType + ", but found type: " + p.GetType());
+               }
+
+               if (this.GetType() != objType)
+               {
+                       Test.result = false;
+                       Console.WriteLine("Expected this type: " + objType + ", but found type: " + this.GetType());
+               }
+               
+       }
+       
+       public static void ThreadPoolTest()
+       {                       
+               Gen<T> obj = new Gen<T>();
+               objType = obj.GetType();
+
+               TimerCallback tcb = new TimerCallback(obj.Target);
+               Stopwatch testWatch = new Stopwatch();
+               testWatch.Start();
+               Timer timer = new Timer(tcb,obj,Test.delay,Test.period);
+               while (testWatch.ElapsedMilliseconds < Test.timeToRun)
+               {
+                       Thread.Sleep(0);
+               }
+
+               timer.Dispose();
+               testWatch.Stop();
+
+               if (Test.Xcounter > ((testWatch.ElapsedMilliseconds / Test.period)+2))
+               {
+                       Test.result = false;
+                       Console.WriteLine("Expected Timer to run at most " + ((testWatch.ElapsedMilliseconds / Test.period)+2) + " times, but found " + Test.Xcounter + " runs in " + obj.GetType() + " type object.");
+               }               
+
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int delay = 0;
+       public static int period = 30;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static int timeToRun = 5000;
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
diff --git a/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.csproj b/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.csproj
new file mode 100644 (file)
index 0000000..3821d1d
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="tighttimercallback.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/project.json b/tests/src/baseservices/threading/generics/WaitCallback/project.json
new file mode 100644 (file)
index 0000000..c14efc6
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "dependencies": {
+    "System.Diagnostics.Process": "4.0.0-beta-23302",
+    "System.IO": "4.0.10-beta-23302",
+    "System.IO.FileSystem": "4.0.0-beta-23302",
+    "System.IO.FileSystem.Primitives": "4.0.0-beta-23302",
+    "System.Runtime": "4.0.20-beta-23302",
+    "System.Runtime.Extensions": "4.0.10-beta-23302",
+    "System.Runtime.Handles": "4.0.0-beta-23302",
+    "System.Runtime.Loader": "4.0.0-beta-23302",
+    "System.Threading": "4.0.10-beta-23302",
+    "System.Threading.AccessControl": "4.0.0-rc3-23823",
+    "System.Globalization.Calendars": "4.0.0-beta-23302",
+    "System.Globalization": "4.0.10-beta-23302",
+    "System.Text.Encoding": "4.0.10-beta-23302",
+    "System.Runtime.InteropServices": "4.0.20-beta-23302",
+    "System.Collections": "4.0.10-beta-23302",
+    "System.Console": "4.0.0-beta-23302",
+    "System.Reflection": "4.0.10-beta-23302",
+    "System.Reflection.Primitives": "4.0.0-beta-23302",
+    "System.ComponentModel": "4.0.1-beta-23302",
+    "System.Xml.ReaderWriter": "4.0.11-beta-23302",
+    "System.Collections.NonGeneric": "4.0.1-beta-23302",
+    "System.Collections.Specialized": "4.0.1-beta-23302",
+    "System.Linq": "4.0.1-beta-23302",
+    "System.Linq.Queryable": "4.0.1-beta-23302",
+    "System.Xml.XmlSerializer": "4.0.11-beta-23302",
+    "System.Xml.XmlDocument": "4.0.1-beta-23302",
+    "System.Xml.XDocument": "4.0.11-beta-23302"
+  },
+  "frameworks": {
+    "dnxcore50": {}
+  }
+}
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread01.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread01.cs
new file mode 100644 (file)
index 0000000..261b95d
--- /dev/null
@@ -0,0 +1,81 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads = 50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread01.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread01.csproj
new file mode 100644 (file)
index 0000000..7235f93
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread01.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread02.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread02.cs
new file mode 100644 (file)
index 0000000..e3d707c
--- /dev/null
@@ -0,0 +1,81 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public virtual void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread02.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread02.csproj
new file mode 100644 (file)
index 0000000..7d8a014
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread02.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread03.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread03.cs
new file mode 100644 (file)
index 0000000..09d026a
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+class Gen 
+{
+       public void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen obj = new Gen();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread03.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread03.csproj
new file mode 100644 (file)
index 0000000..198813f
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread03.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread04.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread04.cs
new file mode 100644 (file)
index 0000000..38d00f3
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+class Gen 
+{
+       public virtual void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen obj = new Gen();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread04.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread04.csproj
new file mode 100644 (file)
index 0000000..8480ccb
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread04.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread05.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread05.cs
new file mode 100644 (file)
index 0000000..bf0fb64
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread05.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread05.csproj
new file mode 100644 (file)
index 0000000..846cdcc
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread05.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread06.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread06.cs
new file mode 100644 (file)
index 0000000..d031dff
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public virtual void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread06.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread06.csproj
new file mode 100644 (file)
index 0000000..655d5d5
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread06.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread07.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread07.cs
new file mode 100644 (file)
index 0000000..bd040a6
--- /dev/null
@@ -0,0 +1,81 @@
+using System;
+using System.Threading;
+
+struct Gen<T> 
+{
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread07.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread07.csproj
new file mode 100644 (file)
index 0000000..9368e18
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread07.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread08.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread08.cs
new file mode 100644 (file)
index 0000000..72caf04
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+struct Gen 
+{
+       public void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen obj = new Gen();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread08.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread08.csproj
new file mode 100644 (file)
index 0000000..52167e1
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread08.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread09.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread09.cs
new file mode 100644 (file)
index 0000000..5376b1d
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+struct Gen<T> 
+{
+       public void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread09.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread09.csproj
new file mode 100644 (file)
index 0000000..4432725
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread09.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread10.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread10.cs
new file mode 100644 (file)
index 0000000..11fc065
--- /dev/null
@@ -0,0 +1,91 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+class Gen<T> : IGen<T>
+{
+       public T Dummy(T t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<T> obj = new Gen<T>();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread10.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread10.csproj
new file mode 100644 (file)
index 0000000..221aee2
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread10.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread11.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread11.cs
new file mode 100644 (file)
index 0000000..1a5488b
--- /dev/null
@@ -0,0 +1,91 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+struct Gen<T> : IGen<T>
+{
+       public T Dummy(T t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<T> obj = new Gen<T>();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread11.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread11.csproj
new file mode 100644 (file)
index 0000000..fd4dad1
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread11.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread12.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread12.cs
new file mode 100644 (file)
index 0000000..e67c2ca
--- /dev/null
@@ -0,0 +1,91 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+class Gen<T> : IGen<T>
+{
+       public T Dummy(T t) { return t; }
+
+       public virtual void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<T> obj = new Gen<T>();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread12.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread12.csproj
new file mode 100644 (file)
index 0000000..36ac224
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread12.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread13.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread13.cs
new file mode 100644 (file)
index 0000000..220adfb
--- /dev/null
@@ -0,0 +1,233 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+class GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<int> obj = new GenInt();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<double> obj = new GenDouble();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+
+class GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<string> obj = new GenString();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<object> obj = new GenObject();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<Guid> obj = new GenGuid();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest();
+               GenDouble.ThreadPoolTest();
+               GenString.ThreadPoolTest();
+               GenObject.ThreadPoolTest(); 
+               GenGuid.ThreadPoolTest(); 
+               
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread13.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread13.csproj
new file mode 100644 (file)
index 0000000..9712549
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread13.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread14.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread14.cs
new file mode 100644 (file)
index 0000000..032ef73
--- /dev/null
@@ -0,0 +1,233 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+struct GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<int> obj = new GenInt();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<double> obj = new GenDouble();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+
+struct GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<string> obj = new GenString();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<object> obj = new GenObject();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<Guid> obj = new GenGuid();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest();
+               GenDouble.ThreadPoolTest();
+               GenString.ThreadPoolTest();
+               GenObject.ThreadPoolTest(); 
+               GenGuid.ThreadPoolTest(); 
+               
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread14.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread14.csproj
new file mode 100644 (file)
index 0000000..81496bf
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread14.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread15.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread15.cs
new file mode 100644 (file)
index 0000000..e675f55
--- /dev/null
@@ -0,0 +1,233 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target(object p);
+       T Dummy(T t);
+}
+
+class GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public virtual void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<int> obj = new GenInt();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public virtual void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<double> obj = new GenDouble();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+
+class GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public virtual void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<string> obj = new GenString();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public virtual void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<object> obj = new GenObject();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public virtual void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+
+            Interlocked.Increment(ref Test.Xcounter);
+            evt.Set();
+       }
+       
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<Guid> obj = new GenGuid();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest();
+               GenDouble.ThreadPoolTest();
+               GenString.ThreadPoolTest();
+               GenObject.ThreadPoolTest(); 
+               GenGuid.ThreadPoolTest(); 
+               
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread15.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread15.csproj
new file mode 100644 (file)
index 0000000..63f07aa
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread15.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread16.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread16.cs
new file mode 100644 (file)
index 0000000..f5a6c3f
--- /dev/null
@@ -0,0 +1,82 @@
+using System;
+using System.Threading;
+
+interface IGen
+{
+       void Target<U>(object p);
+}
+
+class Gen : IGen
+{
+       public void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen obj = new Gen();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread16.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread16.csproj
new file mode 100644 (file)
index 0000000..5a3858f
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread16.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread17.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread17.cs
new file mode 100644 (file)
index 0000000..b55f7d8
--- /dev/null
@@ -0,0 +1,82 @@
+using System;
+using System.Threading;
+
+interface IGen
+{
+       void Target<U>(object p);
+}
+
+struct Gen : IGen
+{
+       public void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen obj = new Gen();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread17.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread17.csproj
new file mode 100644 (file)
index 0000000..c6dfdc3
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread17.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread18.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread18.cs
new file mode 100644 (file)
index 0000000..a9b4b76
--- /dev/null
@@ -0,0 +1,82 @@
+using System;
+using System.Threading;
+
+interface IGen
+{
+       void Target<U>(object p);
+}
+
+class Gen : IGen
+{
+       public virtual void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen obj = new Gen();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread18.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread18.csproj
new file mode 100644 (file)
index 0000000..c3b4d62
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread18.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread19.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread19.cs
new file mode 100644 (file)
index 0000000..e349af5
--- /dev/null
@@ -0,0 +1,86 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+class Gen<T> : IGen<T>
+{
+       public T Dummy(T t) {return t;}
+
+       public void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread19.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread19.csproj
new file mode 100644 (file)
index 0000000..44e70db
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread19.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread20.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread20.cs
new file mode 100644 (file)
index 0000000..0d9fbc4
--- /dev/null
@@ -0,0 +1,86 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+struct Gen<T> : IGen<T>
+{
+       public T Dummy(T t) {return t;}
+
+       public void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread20.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread20.csproj
new file mode 100644 (file)
index 0000000..362a53f
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread20.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread21.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread21.cs
new file mode 100644 (file)
index 0000000..eabd6fc
--- /dev/null
@@ -0,0 +1,86 @@
+using System;
+using System.Threading;
+
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+class Gen<T> : IGen<T>
+{
+       public T Dummy(T t) {return t;}
+
+       public virtual void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread21.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread21.csproj
new file mode 100644 (file)
index 0000000..aeaaee7
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread21.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread22.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread22.cs
new file mode 100644 (file)
index 0000000..2ba7e54
--- /dev/null
@@ -0,0 +1,268 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+class GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+               Interlocked.Increment(ref Test.Xcounter);
+               evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<int> obj = new GenInt();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+
+        Interlocked.Increment(ref Test.Xcounter);
+        evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<double> obj = new GenDouble();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+
+class GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+
+        Interlocked.Increment(ref Test.Xcounter);
+        evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<string> obj = new GenString();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+
+        Interlocked.Increment(ref Test.Xcounter);
+        evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<object> obj = new GenObject();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+
+        Interlocked.Increment(ref Test.Xcounter);
+        evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<Guid> obj = new GenGuid();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest<int>();
+               GenDouble.ThreadPoolTest<int>();
+               GenString.ThreadPoolTest<int>();
+               GenObject.ThreadPoolTest<int>(); 
+               GenGuid.ThreadPoolTest<int>(); 
+
+               GenInt.ThreadPoolTest<double>();
+               GenDouble.ThreadPoolTest<double>();
+               GenString.ThreadPoolTest<double>();
+               GenObject.ThreadPoolTest<double>(); 
+               GenGuid.ThreadPoolTest<double>(); 
+
+               GenInt.ThreadPoolTest<string>();
+               GenDouble.ThreadPoolTest<string>();
+               GenString.ThreadPoolTest<string>();
+               GenObject.ThreadPoolTest<string>(); 
+               GenGuid.ThreadPoolTest<string>(); 
+
+               GenInt.ThreadPoolTest<object>();
+               GenDouble.ThreadPoolTest<object>();
+               GenString.ThreadPoolTest<object>();
+               GenObject.ThreadPoolTest<object>(); 
+               GenGuid.ThreadPoolTest<object>(); 
+
+               GenInt.ThreadPoolTest<Guid>();
+               GenDouble.ThreadPoolTest<Guid>();
+               GenString.ThreadPoolTest<Guid>();
+               GenObject.ThreadPoolTest<Guid>(); 
+               GenGuid.ThreadPoolTest<Guid>(); 
+
+       
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread22.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread22.csproj
new file mode 100644 (file)
index 0000000..bdc60d5
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread22.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread23.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread23.cs
new file mode 100644 (file)
index 0000000..55e3b64
--- /dev/null
@@ -0,0 +1,266 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+struct GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+               Interlocked.Increment(ref Test.Xcounter);
+               evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<int> obj = new GenInt();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+        Interlocked.Increment(ref Test.Xcounter);
+        evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<double> obj = new GenDouble();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+
+struct GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+        Interlocked.Increment(ref Test.Xcounter);
+        evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<string> obj = new GenString();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+
+        Interlocked.Increment(ref Test.Xcounter);
+        evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<object> obj = new GenObject();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+struct GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+
+        Interlocked.Increment(ref Test.Xcounter);
+        evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<Guid> obj = new GenGuid();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest<int>();
+               GenDouble.ThreadPoolTest<int>();
+               GenString.ThreadPoolTest<int>();
+               GenObject.ThreadPoolTest<int>(); 
+               GenGuid.ThreadPoolTest<int>(); 
+
+               GenInt.ThreadPoolTest<double>();
+               GenDouble.ThreadPoolTest<double>();
+               GenString.ThreadPoolTest<double>();
+               GenObject.ThreadPoolTest<double>(); 
+               GenGuid.ThreadPoolTest<double>(); 
+
+               GenInt.ThreadPoolTest<string>();
+               GenDouble.ThreadPoolTest<string>();
+               GenString.ThreadPoolTest<string>();
+               GenObject.ThreadPoolTest<string>(); 
+               GenGuid.ThreadPoolTest<string>(); 
+
+               GenInt.ThreadPoolTest<object>();
+               GenDouble.ThreadPoolTest<object>();
+               GenString.ThreadPoolTest<object>();
+               GenObject.ThreadPoolTest<object>(); 
+               GenGuid.ThreadPoolTest<object>(); 
+
+               GenInt.ThreadPoolTest<Guid>();
+               GenDouble.ThreadPoolTest<Guid>();
+               GenString.ThreadPoolTest<Guid>();
+               GenObject.ThreadPoolTest<Guid>(); 
+               GenGuid.ThreadPoolTest<Guid>(); 
+
+       
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread23.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread23.csproj
new file mode 100644 (file)
index 0000000..d67aaa5
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread23.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread24.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread24.cs
new file mode 100644 (file)
index 0000000..1116522
--- /dev/null
@@ -0,0 +1,264 @@
+using System;
+using System.Threading;
+
+interface IGen<T>
+{
+       void Target<U>(object p);
+       T Dummy(T t);
+}
+
+class GenInt : IGen<int>
+{
+       public int Dummy(int t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+               Interlocked.Increment(ref Test.Xcounter);
+               evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<int> obj = new GenInt();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenDouble : IGen<double>
+{
+       public double Dummy(double t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+        Interlocked.Increment(ref Test.Xcounter);
+        evt.Set();
+    }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<double> obj = new GenDouble();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+
+class GenString : IGen<string>
+{
+       public string Dummy(string t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+               Interlocked.Increment(ref Test.Xcounter);
+               evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<string> obj = new GenString();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenObject : IGen<object>
+{
+       public object Dummy(object t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+               Interlocked.Increment(ref Test.Xcounter);
+               evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<object> obj = new GenObject();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+class GenGuid : IGen<Guid>
+{
+       public Guid Dummy(Guid t) { return t; }
+
+       public virtual void Target<U>(object p)
+       {               
+               //dummy line to avoid warnings
+               Test.Eval(typeof(U)!=p.GetType());
+               ManualResetEvent evt = (ManualResetEvent) p;
+               Interlocked.Increment(ref Test.Xcounter);
+               evt.Set();
+       }
+       
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               IGen<Guid> obj = new GenGuid();
+
+               for (int i = 0; i <Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(obj.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+       
+               GenInt.ThreadPoolTest<int>();
+               GenDouble.ThreadPoolTest<int>();
+               GenString.ThreadPoolTest<int>();
+               GenObject.ThreadPoolTest<int>(); 
+               GenGuid.ThreadPoolTest<int>(); 
+
+               GenInt.ThreadPoolTest<double>();
+               GenDouble.ThreadPoolTest<double>();
+               GenString.ThreadPoolTest<double>();
+               GenObject.ThreadPoolTest<double>(); 
+               GenGuid.ThreadPoolTest<double>(); 
+
+               GenInt.ThreadPoolTest<string>();
+               GenDouble.ThreadPoolTest<string>();
+               GenString.ThreadPoolTest<string>();
+               GenObject.ThreadPoolTest<string>(); 
+               GenGuid.ThreadPoolTest<string>(); 
+
+               GenInt.ThreadPoolTest<object>();
+               GenDouble.ThreadPoolTest<object>();
+               GenString.ThreadPoolTest<object>();
+               GenObject.ThreadPoolTest<object>(); 
+               GenGuid.ThreadPoolTest<object>(); 
+
+               GenInt.ThreadPoolTest<Guid>();
+               GenDouble.ThreadPoolTest<Guid>();
+               GenString.ThreadPoolTest<Guid>();
+               GenObject.ThreadPoolTest<Guid>(); 
+               GenGuid.ThreadPoolTest<Guid>(); 
+
+       
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread24.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread24.csproj
new file mode 100644 (file)
index 0000000..ddb4ca4
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread24.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread25.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread25.cs
new file mode 100644 (file)
index 0000000..a7466d1
--- /dev/null
@@ -0,0 +1,81 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public static void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(Gen<T>.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads = 50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread25.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread25.csproj
new file mode 100644 (file)
index 0000000..5ff4103
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread25.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread26.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread26.cs
new file mode 100644 (file)
index 0000000..dfbbfc7
--- /dev/null
@@ -0,0 +1,83 @@
+using System;
+using System.Threading;
+
+struct Gen<T> 
+{
+       public static void Target(object p)
+       {               
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+#pragma warning disable 219
+               Gen<T> obj = new Gen<T>();
+#pragma warning restore
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(Gen<T>.Target);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads = 50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest();
+               Gen<double>.ThreadPoolTest();
+               Gen<string>.ThreadPoolTest();
+               Gen<object>.ThreadPoolTest(); 
+               Gen<Guid>.ThreadPoolTest(); 
+
+               Gen<int[]>.ThreadPoolTest(); 
+               Gen<double[,]>.ThreadPoolTest();
+               Gen<string[][][]>.ThreadPoolTest(); 
+               Gen<object[,,,]>.ThreadPoolTest();
+               Gen<Guid[][,,,][]>.ThreadPoolTest();
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread26.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread26.csproj
new file mode 100644 (file)
index 0000000..f05ac41
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread26.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread27.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread27.cs
new file mode 100644 (file)
index 0000000..f97794a
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+class Gen<T> 
+{
+       public static void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               Gen<T> obj = new Gen<T>();
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(Gen<T>.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread27.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread27.csproj
new file mode 100644 (file)
index 0000000..9fbe49c
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread27.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread28.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread28.cs
new file mode 100644 (file)
index 0000000..63f5828
--- /dev/null
@@ -0,0 +1,77 @@
+using System;
+using System.Threading;
+
+struct Gen<T> 
+{
+       public static void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+#pragma warning disable 219
+               Gen<T> obj = new Gen<T>();
+#pragma warning restore
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(Gen<T>.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen<int>.ThreadPoolTest<object>();
+               Gen<double>.ThreadPoolTest<string>();
+               Gen<string>.ThreadPoolTest<Guid>();
+               Gen<object>.ThreadPoolTest<int>(); 
+               Gen<Guid>.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread28.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread28.csproj
new file mode 100644 (file)
index 0000000..0b9be38
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread28.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread29.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread29.cs
new file mode 100644 (file)
index 0000000..5bb1305
--- /dev/null
@@ -0,0 +1,75 @@
+using System;
+using System.Threading;
+
+class Gen 
+{
+       public static void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(Gen.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread29.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread29.csproj
new file mode 100644 (file)
index 0000000..63c8e84
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread29.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread30.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread30.cs
new file mode 100644 (file)
index 0000000..bb6be40
--- /dev/null
@@ -0,0 +1,75 @@
+using System;
+using System.Threading;
+
+struct Gen 
+{
+       public static void Target<U>(object p)
+       {               
+                       //dummy line to avoid warnings
+                       Test.Eval(typeof(U)!=p.GetType());
+                       ManualResetEvent evt = (ManualResetEvent) p;
+                       Interlocked.Increment(ref Test.Xcounter);
+                       evt.Set();
+       }
+       public static void ThreadPoolTest<U>()
+       {
+               ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads];
+               WaitHandle[] hdls = new WaitHandle[Test.nThreads];
+
+               for (int i=0; i<Test.nThreads; i++)
+               {
+                       evts[i] = new ManualResetEvent(false);
+                       hdls[i] = (WaitHandle) evts[i];
+               }
+
+               for (int i = 0; i < Test.nThreads; i++)
+               {       
+                       WaitCallback cb = new WaitCallback(Gen.Target<U>);
+                       ThreadPool.QueueUserWorkItem(cb,evts[i]);
+               }
+
+               WaitHandle.WaitAll(hdls);
+               Test.Eval(Test.Xcounter==Test.nThreads);
+               Test.Xcounter = 0;
+       }
+}
+
+public class Test
+{
+       public static int nThreads =50;
+       public static int counter = 0;
+       public static int Xcounter = 0;
+       public static bool result = true;
+       public static void Eval(bool exp)
+       {
+               counter++;
+               if (!exp)
+               {
+                       result = exp;
+                       Console.WriteLine("Test Failed at location: " + counter);
+               }
+       
+       }
+       
+       public static int Main()
+       {
+               Gen.ThreadPoolTest<object>();
+               Gen.ThreadPoolTest<string>();
+               Gen.ThreadPoolTest<Guid>();
+               Gen.ThreadPoolTest<int>(); 
+               Gen.ThreadPoolTest<double>(); 
+
+               if (result)
+               {
+                       Console.WriteLine("Test Passed");
+                       return 100;
+               }
+               else
+               {
+                       Console.WriteLine("Test Failed");
+                       return 1;
+               }
+       }
+}              
+
+
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread30.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread30.csproj
new file mode 100644 (file)
index 0000000..f5baa79
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
+    <CLRTestKind>BuildAndRun</CLRTestKind>
+    <CLRTestPriority>0</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+  </PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <ItemGroup>
+    <!-- Add Compile Object Here -->
+    <Compile Include="thread30.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file