473,407 Members | 2,312 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,407 software developers and data experts.

threading question

CK
I have the following code in a windows service, when I start the windows
service process1 and process2 work fine ,When process 1) and 2) get
completed process 3) starts and sofar so good. the problem is if the files
in process 1) are all processed and we are in the middle of process 2) , at
this point if i coppy a file to the directory for process 1) then this file
never gets processed and we never enter process 3) . How can I fix this
issue?
and How can I stop the service when process 3) has processed all the files?

Thanks in advance

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

m_threadNewClaimInstitutional.Join();
m_ThreadNewClaimProfessional.Join();
//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();

}
//this is the code for the process 1) , process 2) is similar
private void Process1()

{

//Instantiate the Converter class

Newclass objP= new NewClass();

//Process the Files one by one

while(Directory.GetFiles(IncomingXMLPathPLength>0)

{

if(Directory.Exists(IncomingXMLPathP) && Directory.Exists(PathIntermediate))

{

//Get the File in the directory

DirectoryInfo dir = new DirectoryInfo(IncomingXMLPathP);

FileInfo[] xmlfiles = dir.GetFiles("*.xml");

Thread.Sleep(1000);

foreach( FileInfo file in xmlfiles)

{
string strH="";

string InternalTransactionID="";

//Opens an existing UTF-8 encoded text file for reading.

StreamReader sr = File.OpenText(file.FullName);

string data= sr.ReadToEnd();
strH= objP.ConvertNewCt(data,out InternalTransactionID);

FileInfo outputFile = new
FileInfo(PathIntermediate+InternalTransactionID+". clm");

StreamWriter strWriter =new StreamWriter(File.Open(PathIntermediate+
InternalTransactionID +".clm",FileMode.Create, FileAccess.Write ));

strWriter.Flush();

strWriter.Write(strHMI.ToString());
strWriter.Close();

sr.Close();

file.Delete();

}

}

}

}
Nov 12 '05 #1
0 1032

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

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
7
by: Anthony Nystrom | last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up again... Just curious... If the thread is enabling a form, if the form is disposed is the thread as well? Thanks, ...
4
by: Bob | last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done? - It is OK to pass objects out of the thread? (dumb question maybe but I want to be sure) - What's the best way to...
4
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.