N
NWeller
Well, I think it is odd.
I have written an application that fires off requests at a COM
component written in VB6. I am creating multiple threads, one for each
test.
I know that the threads are being created, I know that the calls are
being made to the COM component, I know that the COM component is being
called and is returning a result.
What is going wrong is that if I create 1 thread then the mEvent.Set
command in processThread does not ever get reached and the result is
that WaitAll never finishes.
If I create 6 threads, all of them fire mEvent.Set except for the first
thread.
If I create 10, all complete except the first one.
I have been looking at this for a few hours and I cannot see what is
going wrong. I have got MTAThread set and I have no idea why this
happening, I have found no pointers searching.
If anyone can explain what I am doing wrong then I would really
appreciate it, I assume it is something daft that I have done. I
suspect that the first thread is sitting there waiting to do something
but nothing is happening and no exceptions are being raised.
Thanks in advance,
Neil
Part of the code follows:
public PCTestScript RunTests()
{
Thread[] threadArray = new Thread[m_Threads];
ManualResetEvent[] manualEvents = new
ManualResetEvent[m_Threads];
WaitHandle[] waitHandle = new WaitHandle[m_Threads];
for(int i = 0; i < m_Threads; i++)
{
manualEvents = new ManualResetEvent(false);
//waitHandle = (WaitHandle) manualEvents;
PCThread pcThread = new PCThread(manualEvents);
pcThread.TestScriptRow=m_pcts.PCTestScriptList;
threadArray = new Thread(new
ThreadStart(pcThread.processThread));
//Code below...
threadArray.Name=i.ToString();
threadArray.Start();
}
// wait for the work items to signal before exiting.
ManualResetEvent.WaitAll(manualEvents);
Console.WriteLine("Finished - Yahoo");
return m_pcts;
}
public void processThread()
{
try
{
PCInterface pcInterface = new PCInterface();
//Call to Com Component....
//This does not get called the FIRST time, why?
mEvent.Set();
}
catch (Exception ex)
{
Console.Out.WriteLine("It errored");
}
}
I have written an application that fires off requests at a COM
component written in VB6. I am creating multiple threads, one for each
test.
I know that the threads are being created, I know that the calls are
being made to the COM component, I know that the COM component is being
called and is returning a result.
What is going wrong is that if I create 1 thread then the mEvent.Set
command in processThread does not ever get reached and the result is
that WaitAll never finishes.
If I create 6 threads, all of them fire mEvent.Set except for the first
thread.
If I create 10, all complete except the first one.
I have been looking at this for a few hours and I cannot see what is
going wrong. I have got MTAThread set and I have no idea why this
happening, I have found no pointers searching.
If anyone can explain what I am doing wrong then I would really
appreciate it, I assume it is something daft that I have done. I
suspect that the first thread is sitting there waiting to do something
but nothing is happening and no exceptions are being raised.
Thanks in advance,
Neil
Part of the code follows:
public PCTestScript RunTests()
{
Thread[] threadArray = new Thread[m_Threads];
ManualResetEvent[] manualEvents = new
ManualResetEvent[m_Threads];
WaitHandle[] waitHandle = new WaitHandle[m_Threads];
for(int i = 0; i < m_Threads; i++)
{
manualEvents = new ManualResetEvent(false);
//waitHandle = (WaitHandle) manualEvents;
PCThread pcThread = new PCThread(manualEvents);
pcThread.TestScriptRow=m_pcts.PCTestScriptList;
threadArray = new Thread(new
ThreadStart(pcThread.processThread));
//Code below...
threadArray.Name=i.ToString();
threadArray.Start();
}
// wait for the work items to signal before exiting.
ManualResetEvent.WaitAll(manualEvents);
Console.WriteLine("Finished - Yahoo");
return m_pcts;
}
public void processThread()
{
try
{
PCInterface pcInterface = new PCInterface();
//Call to Com Component....
//This does not get called the FIRST time, why?
mEvent.Set();
}
catch (Exception ex)
{
Console.Out.WriteLine("It errored");
}
}