473,796 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 19123
Hi David,

you could call back from the second thread to the main thread (where your
form is beeing displayed) with the ThreadPool.Queu eUserWorkItem 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.DoE vents like this:

<code>
using System.Diagnost ics;
using System.Windows. Forms;

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

{

System.Windows. Forms.Applicati on.DoEvents();

}

</code>

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

<da***@guenthne rs.com> schrieb im Newsbeitrag
news:11******** **************@ f14g2000cwb.goo glegroups.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
9874
by: Frank | last post by:
What is the best IDE for developing PHP applications? What do you use and why? Thanks.
47
3885
by: Richard Hayden | last post by:
Hi, I have the following code: /******************************** file1.c #include <iostream> extern void dummy(); inline int testfunc() {
8
32677
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 have to read after the external program finishes. I use the transfertext method to read the file. The problem is that the SHELL command executes external programs in an asynch way. In other words, the VBA code will continue running and NOT...
4
20144
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 will be better if an external program could be triggered. Any suggestions?
5
3648
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 New System.Diagnostics.Process 'p.Start(MDEPDirStr & "macrun.exe", sPPTOut) p.Start("C:\WINDOWS\SYSTEM32\CALC.EXE") 'p.Start("C:\WINDOWS\SYSTEM32\macrun.exe", sPPTOut)
0
1814
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 system is Windows XP Pro and the test machine is Windows 2003, both running the latest upgrades; Visual Studio 2005 is installed on the development system and the .Net 2.0 framework is installed on the test system. The two systems do not have the...
2
5334
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>make_buildinfo.obj : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _make_buildinfo2 Ask on python-list@python.org . - Josiah
1
1589
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 company that uses a program that stores data in an SQL database running off a Firebird engine The program itself doesnt come with database management/administration module, so I'll need to use an external program for manipulating data in the...
2
2720
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 rpcrt4.lib ole32.lib oleaut32.lib uuid.lib Creating library libsq00.lib and object libsq00.exp libq00.lib(ootb.obj) : error LNK2019: unresolved external symbol _ldap_unbind@4
0
9673
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
9525
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
10452
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
10221
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
10169
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
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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...
1
4115
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
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.