473,775 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Raising process exit event

WRH
Hello
I used the VS designer to set up Process code as follows...
the problem is, although the process is executed, when
it is shut down I never get the Exited event.
....
private System.Diagnost ics.Process process1;
....
this.process1 = new System.Diagnost ics.Process();
....

// process1
//
this.process1.E nableRaisingEve nts = true;
this.process1.S ynchronizingObj ect = this;
this.process1.E xited += new System.EventHan dler(this.proce ss1_Exited);
....
process1.StartI nfo.FileName = @"F:\G\MS Paint";
process1.Start( );

....

private void process1_Exited (object sender, System.EventArg s e)
{
MessageBox.Show ("Exited");
}
Feb 6 '06 #1
3 13485
WRH
Problem solved. It turns out that if the process is a shortcut,
ie .lnk then the process runs but does not raise the event.

"WRH" <no*****@videot ron.ca> wrote in message
news:uY******** *****@tk2msftng p13.phx.gbl...
Hello
I used the VS designer to set up Process code as follows...
the problem is, although the process is executed, when
it is shut down I never get the Exited event.
...
private System.Diagnost ics.Process process1;
...
this.process1 = new System.Diagnost ics.Process();
...

// process1
//
this.process1.E nableRaisingEve nts = true;
this.process1.S ynchronizingObj ect = this;
this.process1.E xited += new System.EventHan dler(this.proce ss1_Exited);
...
process1.StartI nfo.FileName = @"F:\G\MS Paint";
process1.Start( );

...

private void process1_Exited (object sender, System.EventArg s e)
{
MessageBox.Show ("Exited");
}

Feb 6 '06 #2
WRH,

That should work perfectly. In order to get that event fired you need to set
EnableRaisingEv ents = true; I can see you did that.

My suggestion is to double check if this flag is set.

Another case where you may not get the event fired (I just want to make
clear that this is very unlikely and I don't believe this is your problem)
is because you set SynchronizingOb ject to the parent control. In this case
the code will try to marshal the event call to the UI thread. Internally
this is done using the windows message loop and it should work perfectly.
There might be a catch though. If the parent control is a user control for
example and the control is created using the *new* operator, but not added
to any Controls collection it might be possible that the message loop
doesn't serve these control or the control might be created in a worker
theread that has no message loop at all. Again this is very hypothetical,
but there are chances that you may recognize similar situation in your code.
--
HTH
Stoitcho Goutsev (100)

"WRH" <no*****@videot ron.ca> wrote in message
news:uY******** *****@tk2msftng p13.phx.gbl...
Hello
I used the VS designer to set up Process code as follows...
the problem is, although the process is executed, when
it is shut down I never get the Exited event.
...
private System.Diagnost ics.Process process1;
...
this.process1 = new System.Diagnost ics.Process();
...

// process1
//
this.process1.E nableRaisingEve nts = true;
this.process1.S ynchronizingObj ect = this;
this.process1.E xited += new System.EventHan dler(this.proce ss1_Exited);
...
process1.StartI nfo.FileName = @"F:\G\MS Paint";
process1.Start( );

...

private void process1_Exited (object sender, System.EventArg s e)
{
MessageBox.Show ("Exited");
}

Feb 7 '06 #3
WRH
Thanks for the response and the info. I did find this particular problem and
posted this note...

Problem solved. It turns out that if the process is a shortcut,
ie .lnk then the process runs but does not raise the event.

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:u1******** *****@tk2msftng p13.phx.gbl...
WRH,

That should work perfectly. In order to get that event fired you need to
set EnableRaisingEv ents = true; I can see you did that.

My suggestion is to double check if this flag is set.

Another case where you may not get the event fired (I just want to make
clear that this is very unlikely and I don't believe this is your problem)
is because you set SynchronizingOb ject to the parent control. In this case
the code will try to marshal the event call to the UI thread. Internally
this is done using the windows message loop and it should work perfectly.
There might be a catch though. If the parent control is a user control for
example and the control is created using the *new* operator, but not added
to any Controls collection it might be possible that the message loop
doesn't serve these control or the control might be created in a worker
theread that has no message loop at all. Again this is very hypothetical,
but there are chances that you may recognize similar situation in your
code.
--
HTH
Stoitcho Goutsev (100)

"WRH" <no*****@videot ron.ca> wrote in message
news:uY******** *****@tk2msftng p13.phx.gbl...
Hello
I used the VS designer to set up Process code as follows...
the problem is, although the process is executed, when
it is shut down I never get the Exited event.
...
private System.Diagnost ics.Process process1;
...
this.process1 = new System.Diagnost ics.Process();
...

// process1
//
this.process1.E nableRaisingEve nts = true;
this.process1.S ynchronizingObj ect = this;
this.process1.E xited += new System.EventHan dler(this.proce ss1_Exited);
...
process1.StartI nfo.FileName = @"F:\G\MS Paint";
process1.Start( );

...

private void process1_Exited (object sender, System.EventArg s e)
{
MessageBox.Show ("Exited");
}


Feb 7 '06 #4

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

Similar topics

4
2108
by: serge calderara | last post by:
Dear all, I have a class wich is raising events as normally it should do. having a form in the same assembly wich is catching those events works fne. Raise events gets catch normaly within the form and I can process what I want based on them. If I try to catch raised events by this class but within a form located in a different assembly, I am not able to
18
4893
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
3
5134
by: David | last post by:
Hi, Ive been trying to work this out for the past 2 days now and im not getting anywhere fast. The problem i have is that i am using Asynchronous sockets to create a Socket Client library. When i try to connect to a server that doesnt exist it raises a "Connection forcibly rejected by the resmote host" SocketException.
6
2881
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a TimerState object similar to the example in the System.Threading.Timer documentation. The method which handles the timer events, among other things, periodically calls a method in this TimerState object which raises an event to the startup form,...
4
17270
by: rawCoder | last post by:
Hi all, How Can You Raise Events Asynchronously ? Now for the details ... I want to do inter modular communication using events in such a way that the contributing modules need not maintain the reference to any module.
3
2548
by: Chris Dunaway | last post by:
Consider the following simple classes/interfaces defined below. When the derived class raises the events, on which thread is the event code run? Do I need to do anything to catch the events in my main app? What threading issues do I have if several of these fileproc classes are instantiated and run at the same time? '*** BEGIN CODE Public Interface IFileProc ReadOnly Property FileMask() As String Function Process(ByVal filename As...
3
30628
by: Woo Mun Foong | last post by:
I have a checkbox, when enable, allows me to proceed with what I like to do. However, I need to check a certain conditions before I allow the checked box to be checked, if condition is not fullfill I need to cancel the Checked State. I captured the Mouse Click event inside CheckedChanged and CheckedStateChanged Events but it goes into infinite loops. I am using VB.NET 2003 and .NET 1.1 Briefly, my code is as follows:-
4
3329
by: Nick | last post by:
Hi there, I'm running a process object within a .NET app, very simple, the process is declared with events, i'm handling the Exit event and running a win32 application. No matter how the process closes the event is never raised, is this because it is a win32 app rather than .NET? I've tried closing, killing, and even sending a WM_CLOSE event to the window, it closes but no event is raised. My only other solution was to keep...
7
2873
by: Christian Cambier | last post by:
Hi, I have a textbox in a web user control. I then add the usercontrol to a web form. I also add a label in the web form. Now, when I press a key in the textbox, i want to display some text in the label. I tried by raising events as used in Winforms but it is not as easy as
0
9454
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
10270
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
10109
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...
0
9916
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...
0
8939
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
7464
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
6718
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
4017
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
3611
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.