473,387 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can I set the ProcessorAffinity of a thread?

I know that I can use ProcessThread.ProcessAffinity. But I didn't found an
answer how I can map a ProcessThread to a Thread (they don't seem to be the
same). Because I can not set the affinity of the thread when creating it
does .NET find the best solution for me if I have a multi processor system?

I tried the following code to set the affinity but I can not be sure that is
working. How can I check that the thread is really using another CPU?
ProcessThread.ProcessAffinity allows me only to set the affinity but not to
get it :( I would like to create another application just for checking the
threads....

Hope you have an answer for me....
int id = AppDomain.GetCurrentThreadId();

Process process = Process.GetCurrentProcess();

foreach( ProcessThread processThread in process.Threads )

{

if( processThread.Id == id )

{

processThread.ProcessorAffinity = new IntPtr( processorAffinity );

}

}
Nov 16 '05 #1
0 2238

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: adeger | last post by:
Having trouble with my first forays into threads. Basically, the threads don't seem to be working in parallel (or you might say are blocking). I've boiled my problems to the following short code...
4
by: Gilles Leblanc | last post by:
Hi I have started a small project with PyOpenGL. I am wondering what are the options for a GUI. So far I checked PyUI but it has some problems with 3d rendering outside the Windows platform. I...
7
by: Ivan | last post by:
Hi I have following problem: I'm creating two threads who are performing some tasks. When one thread finished I would like to restart her again (e.g. new job). Following example demonstrates...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
5
by: Razzie | last post by:
Hi all, A question from someone on a website got me thinking about this, and I wondered if anyone could explain this. A System.Threading.Timer object is garbage collected if it has no...
16
by: droopytoon | last post by:
Hi, I start a new thread (previous one was "thread timing") because I have isolated my problem. It has nothing to do with calling unmanaged C++ code (I removed it in a test application). I...
0
by: Dante | last post by:
I know that I can use ProcessThread.ProcessAffinity. But I didn't found an answer how I can map a ProcessThread to a Thread (they don't seem to be the same). Because I can not set the affinity of...
8
by: [Yosi] | last post by:
I create new thread as following: Thread mThread = new Thread(new ThreadStart(m_ClassThread.Go)); In my system I have 2 Process devices ,(CPU0 and CPU1) , I want to create 3 Threads, 2 of those...
9
by: mareal | last post by:
I have noticed how the thread I created just stops running. I have added several exceptions to the thread System.Threading.SynchronizationLockException System.Threading.ThreadAbortException...
0
by: Nicolas Zenou | last post by:
Hey everyone, I am new to .NET Framework programing and I have an important question. In fact, I need to launch many thread in my application. I assume to use backgroundWorker which are really...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.