threading question

21/12/2004 - 10:24 por CK | Informe spam
I have the following code in a windows service, when I start the windows
service process1 and process2 work fine , but final process (3) doesnt get
called. i stop and restart the windows service and the final process(3) gets
called. what am I doing wrong with the threading? by the way
Directory.GetFiles(IncomingXMLPath1).Length is some global outcome from
process 1.

Thanks

1)
m_threadNewClaimInstitutional = new Thread(new
System.Threading.ThreadStart(process1));

m_threadNewClaimInstitutional.Start();

2)

m_ThreadNewClaimProfessional= new Thread(new
System.Threading.ThreadStart(process2));

m_ThreadNewClaimProfessional.Start();

//when all the files have been processed in both the process1 and process2
directories

//then is the final process

#)final

if(Directory.GetFiles(IncomingXMLPath1).Length==0 &&
Directory.GetFiles(IncomingXMLPath2).Length==0)

{

m_ThreadFinall = new Thread(new System.Threading.ThreadStart(process3));

m_ThreadFinall.Start();

}
 

Leer las respuestas

#1 A.Poblacion
21/12/2004 - 09:13 | Informe spam
I don't think you are doing anything wrong with the threading itself.
Rather, it looks like you aren't waiting properly for the completion of
processes 1) and 2) before going into the final step. Therefore, it checks
for wether the directories are empty, finds that they aren't (because
processes 1 and 2 haven't finished), and skips the process3. When you start
the service again, there has been enough time to compete precesses 1 and 2,
the directories have been emptied and the check succeeds, enabling process3
to run.

You should post the missing piece of code (where you check for completion of
1 and 2) for us to take a look and try to guess why it is not working
properly.


"CK" wrote in message
news:%
I have the following code in a windows service, when I start the windows
service process1 and process2 work fine , but final process (3) doesnt


get
called. i stop and restart the windows service and the final process(3)


gets
called. what am I doing wrong with the threading? by the way
Directory.GetFiles(IncomingXMLPath1).Length is some global outcome from
process 1.

Thanks

1)
m_threadNewClaimInstitutional = new Thread(new
System.Threading.ThreadStart(process1));

m_threadNewClaimInstitutional.Start();

2)

m_ThreadNewClaimProfessional= new Thread(new
System.Threading.ThreadStart(process2));

m_ThreadNewClaimProfessional.Start();

//when all the files have been processed in both the process1 and process2
directories

//then is the final process

#)final

if(Directory.GetFiles(IncomingXMLPath1).Length==0 &&
Directory.GetFiles(IncomingXMLPath2).Length==0)

{

m_ThreadFinall = new Thread(new System.Threading.ThreadStart(process3));

m_ThreadFinall.Start();

}


Preguntas similares