V
Vlad
I have implemented an asyncrhonous execution of a method using the
delegate's BeginInvoke()
I am trying to spin multiple worker threads in a thread pool.
Here is the code:
TestProcess process = new TestProcess(TestProcess);
process.BeginInvoke(args,null,null);
private void TestProcess(args)
{
Thread.CurrentThread.Name = "TestProcess; Group: " + args;
}
However after a while it seems that the TestProcess method starts executing
on the same thread that became inactive.
I get exceptions pointing me to the line where I assign
Thread.CurrentThread.Name as it is already assigned by the previous
execution.
Is this the correct behaviour?
While I understand that the TreadPool object could choose existing thread
resources naturally I thought that the data on that new thread would be
reset.
Is Thread.CurrentThread.Name and exclusion to that rule not not considered
to be part of the thread data?
It basically becomes useless since I cannot uniquely identify the threads
anymore...
Could you please let me know if I am doing something wrong or if that is by
design. If it is by design, please refer me to the KB article or other
resources.
Thanks,
Vlad
delegate's BeginInvoke()
I am trying to spin multiple worker threads in a thread pool.
Here is the code:
TestProcess process = new TestProcess(TestProcess);
process.BeginInvoke(args,null,null);
private void TestProcess(args)
{
Thread.CurrentThread.Name = "TestProcess; Group: " + args;
}
However after a while it seems that the TestProcess method starts executing
on the same thread that became inactive.
I get exceptions pointing me to the line where I assign
Thread.CurrentThread.Name as it is already assigned by the previous
execution.
Is this the correct behaviour?
While I understand that the TreadPool object could choose existing thread
resources naturally I thought that the data on that new thread would be
reset.
Is Thread.CurrentThread.Name and exclusion to that rule not not considered
to be part of the thread data?
It basically becomes useless since I cannot uniquely identify the threads
anymore...
Could you please let me know if I am doing something wrong or if that is by
design. If it is by design, please refer me to the KB article or other
resources.
Thanks,
Vlad