summaryrefslogtreecommitdiff
path: root/tests/src/baseservices/threading/generics/WaitCallback
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/baseservices/threading/generics/WaitCallback')
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread01.cs84
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread01.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread02.cs84
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread02.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread03.cs80
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread03.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread04.cs80
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread04.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread05.cs80
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread05.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread06.cs80
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread06.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread07.cs84
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread07.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread08.cs80
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread08.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread09.cs80
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread09.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread10.cs94
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread10.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread11.cs94
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread11.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread12.cs94
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread12.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread13.cs236
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread13.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread14.cs236
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread14.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread15.cs236
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread15.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread16.cs85
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread16.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread17.cs85
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread17.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread18.cs85
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread18.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread19.cs89
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread19.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread20.cs89
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread20.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread21.cs89
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread21.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread22.cs271
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread22.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread23.cs269
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread23.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread24.cs267
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread24.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread25.cs84
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread25.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread26.cs86
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread26.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread27.cs80
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread27.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread28.cs80
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread28.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread29.cs78
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread29.csproj41
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread30.cs78
-rw-r--r--tests/src/baseservices/threading/generics/WaitCallback/thread30.csproj41
60 files changed, 4767 insertions, 0 deletions
diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread01.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread01.cs
new file mode 100644
index 0000000000..f253494a3d
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread01.cs
@@ -0,0 +1,84 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+class 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
index 0000000000..ce33640b9f
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread01.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread02.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread02.cs
new file mode 100644
index 0000000000..14e58e834a
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread02.cs
@@ -0,0 +1,84 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+class 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
index 0000000000..2c4070edc5
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread02.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread03.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread03.cs
new file mode 100644
index 0000000000..2ca4aa49b5
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread03.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+class 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
index 0000000000..9efacd2e55
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread03.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread04.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread04.cs
new file mode 100644
index 0000000000..de952fe2bb
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread04.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+class 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
index 0000000000..c4a425f31f
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread04.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread05.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread05.cs
new file mode 100644
index 0000000000..504ec78a10
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread05.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+class 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
index 0000000000..038a235252
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread05.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread06.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread06.cs
new file mode 100644
index 0000000000..d5b71c33f0
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread06.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+class 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
index 0000000000..369a3ab6b7
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread06.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread07.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread07.cs
new file mode 100644
index 0000000000..28f2e3864f
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread07.cs
@@ -0,0 +1,84 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..e8c3b4e577
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread07.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread08.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread08.cs
new file mode 100644
index 0000000000..95712b22f0
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread08.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..7eee61e99e
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread08.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread09.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread09.cs
new file mode 100644
index 0000000000..6f2d737d5e
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread09.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..5af4c9d6e7
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread09.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread10.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread10.cs
new file mode 100644
index 0000000000..bd0f595ca9
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread10.cs
@@ -0,0 +1,94 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+
+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
index 0000000000..047d5dd745
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread10.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread11.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread11.cs
new file mode 100644
index 0000000000..d835dfc7db
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread11.cs
@@ -0,0 +1,94 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+
+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
index 0000000000..a2b541b609
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread11.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread12.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread12.cs
new file mode 100644
index 0000000000..82be6836ea
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread12.cs
@@ -0,0 +1,94 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+
+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
index 0000000000..fa3fd88273
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread12.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread13.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread13.cs
new file mode 100644
index 0000000000..e13a83d20e
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread13.cs
@@ -0,0 +1,236 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..4fbaf3afd4
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread13.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread14.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread14.cs
new file mode 100644
index 0000000000..fa68b5cf06
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread14.cs
@@ -0,0 +1,236 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..fec7ca9388
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread14.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread15.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread15.cs
new file mode 100644
index 0000000000..75b7aa3a2e
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread15.cs
@@ -0,0 +1,236 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..186b84536d
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread15.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread16.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread16.cs
new file mode 100644
index 0000000000..48e906b9f5
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread16.cs
@@ -0,0 +1,85 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..3e19a1cdcd
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread16.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread17.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread17.cs
new file mode 100644
index 0000000000..b51bd27627
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread17.cs
@@ -0,0 +1,85 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..6a1044e621
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread17.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread18.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread18.cs
new file mode 100644
index 0000000000..e8f989609a
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread18.cs
@@ -0,0 +1,85 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..137b2c9b4e
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread18.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread19.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread19.cs
new file mode 100644
index 0000000000..9a295c0fca
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread19.cs
@@ -0,0 +1,89 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+
+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
index 0000000000..dcf2f7860c
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread19.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread20.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread20.cs
new file mode 100644
index 0000000000..c6a19a14d0
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread20.cs
@@ -0,0 +1,89 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+
+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
index 0000000000..faaeece6a7
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread20.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread21.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread21.cs
new file mode 100644
index 0000000000..e6c0f6dbe4
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread21.cs
@@ -0,0 +1,89 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+
+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
index 0000000000..1996239dc9
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread21.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread22.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread22.cs
new file mode 100644
index 0000000000..ef2c656de2
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread22.cs
@@ -0,0 +1,271 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..19e7597fb6
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread22.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread23.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread23.cs
new file mode 100644
index 0000000000..7df7392a64
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread23.cs
@@ -0,0 +1,269 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..64f663730e
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread23.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread24.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread24.cs
new file mode 100644
index 0000000000..ca6bfc33fd
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread24.cs
@@ -0,0 +1,267 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..b8b24b0051
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread24.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread25.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread25.cs
new file mode 100644
index 0000000000..973231f41b
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread25.cs
@@ -0,0 +1,84 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+class 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
index 0000000000..50553c69a0
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread25.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread26.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread26.cs
new file mode 100644
index 0000000000..7cc3dce282
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread26.cs
@@ -0,0 +1,86 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..a943885011
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread26.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread27.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread27.cs
new file mode 100644
index 0000000000..bbe99f4cdf
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread27.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+class 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
index 0000000000..f991df64be
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread27.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread28.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread28.cs
new file mode 100644
index 0000000000..ac48e97abf
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread28.cs
@@ -0,0 +1,80 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..88016dee2d
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread28.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread29.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread29.cs
new file mode 100644
index 0000000000..6963728164
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread29.cs
@@ -0,0 +1,78 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+class 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
index 0000000000..4650523f8b
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread29.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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/WaitCallback/thread30.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread30.cs
new file mode 100644
index 0000000000..ef14e682ed
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread30.cs
@@ -0,0 +1,78 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+using System;
+using System.Threading;
+
+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
index 0000000000..d458fca31b
--- /dev/null
+++ b/tests/src/baseservices/threading/generics/WaitCallback/thread30.csproj
@@ -0,0 +1,41 @@
+<?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>1</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>
+ <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