Program 1
-----------
On startup, fork a new thread which uses CreateEvent() (a Win32 API
function), to create a named event (pick any name that you like). After
creating the event, call WaitForSingleObject() on the event (probably with
no time-out value). If this call returns, exit the program.
In the main thread of the program, do whatever the program is supposed to
do. If it wants to exit, because the process is done or the user clicks the
right button or whatever, call CreateEvent()/SetEvent() on the named event,
causing the second thread to exit the application.
Program 2
-----------
When it wants program 1 to run, P/Invoke CreateProcess(). It can keep the
handle to that program and use that to wait for it to exit, if desired
(using WaitForSingleObject()). Or, it can do whatever it wants and, when
it's time to force program 1 to exit, call CreateEvent() and SetEvent()
(with the same event name, obviously), to cause program 1 to exit.
The declarations for all of these Win32 APIs can be found either in the
newsgroup archives or in the OpenNetCF library (or maybe both)...
Paul T.
"Bjoern" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thank you for your response.
> Can you give me a small simple example for a schema in which two programms
> communicate together.
>
> Thx
> -------------------------------
>
>
>
>
> "Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in
message news:<(E-Mail Removed)>...
> > No, there's no way for a random program to assure that it will exit
cleanly
> > as a result of anything in particular that you do from a second
executable.
> > Is the other program yours? If so, you can create a scheme for the
> > applications to communicate with each other.
> >
> > Paul T.
> >
> > "Bjoern" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hi all,
> > > is there a possibility to close an other application in WinCE and
c#.net.
> > > In my main programm i want to start an other programm.
> > > After that i want to close this programm. But this programm should not
> > > be close "hard".
> > > 1. The underprogramm should execute the closing-event before or
> > > 2. The underprogramm should execute my closing-funktion before closing
> > programm.
> > >
> > > Then:
> > > 1.Start underprogramm with my mainprogramm
> > > 2.Controlled close of this underprogramm by close-event or any
> > close-funktion.
> > >
> > > Please give me a detailed response.
> > > Thx
|