473,382 Members | 1,733 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,382 software developers and data experts.

Process.HasExited

I want to make sure my process is completed:

Process.Start();
bool finished = false;
while (!finsihed)
{
Thread.Sleep(1000);
if (Process.HasExited)
{
Thread.Sleep(1000);
finsihed = true;
}
}

Are these correct ?

The reason I inserted Thread.Sleep(1000) before exiting the loop is my
prcess is creating a text file and exporting data to this text file, so I
need to give time for the process to close the text file even it it
finished.
However, I have to run the above code 100 times (ie. to create 100 text
files and export data to 100 text files, I will open the text file after the
above code is executed each time for each text file), sometime I still got
the exception when I tried to open the textfile in my code:
The text file is being used by other process.

So it seems the process has not finished when I tried to open the text file
at run time.
Sep 4 '06 #1
1 5238
..WaitForExit() is easier, but essentially this should work; some complex
apps (e.g. Word) can use IPC (etc) so that the original process just passes
the request to a second (already running) process - is this a possiblity?

Marc
Sep 4 '06 #2

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

Similar topics

0
by: Dan McGuffin | last post by:
I am trying to develop some vb.net code that will will store 1 or more processes in an array of processes, then loop through the array determining when each one has exited. Upon each one exiting, I...
2
by: Shawn Hogan | last post by:
I'm trying to open an instance of the default browser and browse to a URL. I'm seeing an issue with the process class where if i execute my process using this code Dim p As Process = New Process...
7
by: Samantha | last post by:
Hello , I am developping a program for Win98 plateform, and I am stucking with a problem, hope you can help me. I have a program running 2 process : - One process running the Xcopy.exe -...
2
by: Tobias Johansson | last post by:
Hello, I'm having what I believe a security problem to execute an executable file from a windows service in windows server 2003. It works fine in WIN XP SP2 The program(the service) itself...
12
by: Raymond Lewallen | last post by:
How to wait for a process to stop completion is my goal. Obviously, the looping while waiting for the HasExited property is not a solution.. but thats the best I can come up off the top of my...
11
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very...
4
by: garykenneally | last post by:
Hi, Im trying to run a command line application from C# but i having some strange problems with it. Heres the code im using: System.Diagnostics.Process process = new...
6
by: Ashutosh Bhawasinka | last post by:
Hi, I am starting a process and I need to monitor it (wait and check if its still responding). But, I it seems that the Process.HasExited or Process.Exited doesn't work. I just need to know...
1
by: Rick | last post by:
Can anyone tell me how to set the printer using the process class in VB.net, I've tried everything, it always goes to the default printer. My Code: Dim pathToExecutable As String =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
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...

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.