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

Best way to run external program?

I have a simple csharp form with a 'Go' button on it. This event
launches a external exe successfully but the form color becomes white
and does not repaint while that external program runs, usually about 10
seconds.

I tried creating a thread in seperate class to run that process instead
on running it from main thread. This successfully keeps my form from
becoming distorted. However, I do not have any control over when that
thread finshes or a way to notify the form that it finsished.

Is there a way to run this thread and have the main thread wait until
thread completes before main thread continues to process?

Is there a way to have the thread which runs the external exe and
notify or poke the form to say, hey I've finshed running the exe with
this error code for example?

Perhaps I am approaching this all wrong, any suggestions on how to
approach this in a better way?

Thanks in advance.

Rookie csharp guy

Nov 17 '05 #1
1 19046
Hi David,

you could call back from the second thread to the main thread (where your
form is beeing displayed) with the ThreadPool.QueueUserWorkItem method:
http://msdn.microsoft.com/library/de...kitemtopic.asp

If you just want your form to repaint normally and do not need the user
interacting with your form (clicking buttons etc.) you could just use
Application.DoEvents like this:

<code>
using System.Diagnostics;
using System.Windows.Forms;

Process p = Process.Start("notepad.exe");
while (!p.HasExited)

{

System.Windows.Forms.Application.DoEvents();

}

</code>

Regards,
--
Neno Loje [MVP C#]
http://www.dotnet-online.com

<da***@guenthners.com> schrieb im Newsbeitrag
news:11**********************@f14g2000cwb.googlegr oups.com...
I have a simple csharp form with a 'Go' button on it. This event
launches a external exe successfully but the form color becomes white
and does not repaint while that external program runs, usually about 10
seconds.

I tried creating a thread in seperate class to run that process instead
on running it from main thread. This successfully keeps my form from
becoming distorted. However, I do not have any control over when that
thread finshes or a way to notify the form that it finsished.

Is there a way to run this thread and have the main thread wait until
thread completes before main thread continues to process?

Is there a way to have the thread which runs the external exe and
notify or poke the form to say, hey I've finshed running the exe with
this error code for example?

Perhaps I am approaching this all wrong, any suggestions on how to
approach this in a better way?

Thanks in advance.

Rookie csharp guy

Nov 17 '05 #2

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

Similar topics

33
by: Frank | last post by:
What is the best IDE for developing PHP applications? What do you use and why? Thanks.
47
by: Richard Hayden | last post by:
Hi, I have the following code: /******************************** file1.c #include <iostream> extern void dummy(); inline int testfunc() {
8
by: Greg Fierro | last post by:
I would appreciate any help from anyone with the following: I have an external program (window32 based) that I am executing with the VBA SHELL command. This program produces a text file which I...
4
by: My SQL | last post by:
Hi Can I trigger an external program to run when a new record is added to the mysql table? The external program is in C and instead of scanning the table continuously for new insertions, it...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
0
by: Ken Allen | last post by:
The MSDN documentation on remote debugging is a bit sparse, to say the least, and there is almost no information available on the 'best' way to configure this. I should note that my development...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
1
by: Rhadamanthys | last post by:
Hello All I am a relative beginner to SQL databases & new to this forum, so please bear with me if my query is too basic and advise if this question belongs somewhere else I began working at a...
2
by: =?Utf-8?B?YmFzaA==?= | last post by:
Hello, I am compiling a CPP code using Visual studion .net 2003. I get the following error, despite having windldap.h and wldap32.dll in my include and lib paths. Here is the error. uuid.lib...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.