Process.Exit event not being raised

N

Nick

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 monitoring the HasExited property on
a background thread but I would rather use the event as that is what it was
created for. Thanks in advance if anyone has any advice on this!
 
A

Armin Zingler

Nick said:
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 monitoring the HasExited
property on
a background thread but I would rather use the event as that is what
it was created for. Thanks in advance if anyone has any advice on
this!


Did you set the process' EnableRaisingEvents property?


Armin
 
H

Herfried K. Wagner [MVP]

Nick said:
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.

Make sure your process object's 'EnableRaisingEvents' property is set to
true. Alternatively you can start a new thread which starts the other
application and calls the process object's 'WaitForExit' method afterwards.
 
N

Nick

Hi there,

Not to worry, I'm calling the WaitForExit method in a separate thread to
get around the problem.

Nick.
 
N

Nick

Hi Herfried,

Sorry for the delay my pc only got the message today! Anyway's not to
worry now as I have a nice working solution :) Thanks for your and Armin's
help.

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top