Using SetThreadAffinityMask function imported from kernel32.dll in C # code.
- by DotNetBeginner
I am trying to set Thread Affinity using SetThreadAffinityMask function imported from kernel32.dll in C # code of mine.
This is how I import SetThreadAffinityMask function from "kernel32.dll" in my C# .net code
[DllImport("kernel32.dll")]
static extern IntPtr SetThreadAffinityMask(IntPtr hThread, IntPtr dwThreadAffinityMask);
I am creating 3 threads
Thread t1=new Thread(some delegate);
Thread t2=new Thread(some delegate);
Thread t3=new Thread(some delegate);
I wish to set Thread affinity for t1,t2 & t3 for which I am using SetThreadAffinityMask function.
But I am not getting how to pass parameters to this function.
SetThreadAffinityMask takes two parameters
1. HANDLE hThread
2. DWORD_PTR dwThreadAffinityMask
Please help me in using SetThreadAffinityMask function in C#
Thanks in advance !