Using SetThreadAffinityMask function imported from kernel32.dll in C # code.
Posted
by DotNetBeginner
on Stack Overflow
See other posts from Stack Overflow
or by DotNetBeginner
Published on 2010-03-23T08:46:13Z
Indexed on
2010/03/23
8:53 UTC
Read the original article
Hit count: 338
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 !
© Stack Overflow or respective owner