473,806 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Waiting for a Process to Finish

Hi,

I'm starting a process as follows -

Process process = new Process();
process.StartIn fo.UseShellExec ute = false;
process.StartIn fo.FileName = installValue + "\\Lib\\sit e-packages\
\pythonwin\\Pyt honwin.exe";
process.StartIn fo.Arguments = "/run " + script;

process.Start() ;
process.WaitFor Exit();

when the user presses a button on my GUI. The problem is that my
program is blocked until python is closed. Instead, I'd like to
disable all buttons in my appilcation until python is closed. That way
my program is not blocked but I can still stop the user changing
settings until python is closed.

Should I create a Process which polls process.WaitFor Exit() or is
there a better/easier way of doing this?

Thanks,

Barry.

Mar 27 '07 #1
3 2873
<bg***@yahoo.co mwrote in message
news:11******** **************@ l77g2000hsb.goo glegroups.com.. .
Should I create a Process which polls process.WaitFor Exit() or is
there a better/easier way of doing this?
Instead of polling, it is better to connect your code to the event
"Exited" of the Process class.
Mar 27 '07 #2
On 27 Mar, 09:51, "Alberto Poblacion" <earthling-
quitaestoparaco ntes...@poblaci on.orgwrote:
<b...@yahoo.com wrote in message

news:11******** **************@ l77g2000hsb.goo glegroups.com.. .
Should I create a Process which polls process.WaitFor Exit() or is
there a better/easier way of doing this?

Instead of polling, it is better to connect your code to the event
"Exited" of the Process class.
Cool, thanks for the suggestion. I tried it out but I now have another
problem. I now disable my controls before running the Python process,
but when I attempt to re-enable them via the callback for the Exited
event, I am informed that I cannot access the controls from another
thread other than the one they were created in. So I guess I need to
issue an event to my form thread to tell it to re-enable the controls.
But how do I do that?

Thanks again for your help,

Barry.

Mar 27 '07 #3
On Mar 27, 9:33 am, b...@yahoo.com wrote:
Cool, thanks for the suggestion. I tried it out but I now have another
problem. I now disable my controls before running the Python process,
but when I attempt to re-enable them via the callback for the Exited
event, I am informed that I cannot access the controls from another
thread other than the one they were created in. So I guess I need to
issue an event to my form thread to tell it to re-enable the controls.
But how do I do that?
See http://pobox.com/~skeet/csharp/threads/winforms.shtml

Jon

Mar 27 '07 #4

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

Similar topics

1
2648
by: Behrang Dadsetan | last post by:
Hi all, please note that once I finished writing the script someone explained me that there is a command pwait under Solaris... anyway it was fun to write and it did not take long (while I am not a python guru..). And my version is MUUUCH better :) Is there no standard interfaces to the process table? I only found examples of how to do it on the win32 platform. So I parse with re the
39
789
by: jabailo | last post by:
I am looping through a text file, and with each row, I launch a web service, asynchronously. Before I move on to the next step in the process, I want to make sure that all the web services have completed. How can I do this? If I were to just put a Thread.Sleep with some arbitrary number ( say 5 minutes ) would the asynch web services continue to process? Or would they
4
338
by: Steve W | last post by:
Is it possible to keep some communication going between the browser and web server going while waiting for a long running process to finish ? We have one function on our app (ASP.NET / VB.NET) that does a long running update to the database (takes upto 10 mins) and the browser will often time out before it completes. Ideally I'd like to send information back to the browser from the process, but anything that stops the browser timing...
4
8414
by: Dylan Parry | last post by:
Hi folks, I'm writing a program that needs to execute an external program and wait for it to finish running before it can make use of the output from that program. Specifically, the external program converts from one file format to another, and is something that I can't do natively :( So what I need to figure out is how to: a) Start the external program, with parameters
1
2779
by: Simon_21 | last post by:
Hi All, I have a servlet which is invoked from a jsp page. While the serlvet is executing, the jsp page is waiting for the servlet to complete. When the servlet completes, it informs the waiting jsp to redirect to another page. The waiting jsp has implemented onload which will redirect to the page informed by the servlet Server : (tomcat 6.0), Browser - IE 6.0, OS - WinXP
9
6460
by: erikcw | last post by:
Hi, I have a cgi script where users are uploading large files for processing. I want to launch a subprocess to process the file so the user doesn't have to wait for the page to load. What is the correct way to launch subprocess without waiting for the result to return? Thanks!
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9598
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10373
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.