Re: can not delete excutable in Pocket PC [or WinCE] by Paul
Paul
Tue May 11 18:51:02 CDT 2004
For serial I/O, as we've discussed in this group previously, you can close
the port handle from the 'main' thread, causing the ReadFile() or
WriteFile() operation under way on the port to complete with an error.
Since you have to start all of your threads, it seems like you should know
about them. You can use an event as a signal to exit a thread and have that
thread wait on or check periodically the status of the event (it could check
when it gets an error back from ReadFile or WriteFile, for example). When
the event is set, exit the thread cleanly. For waiting for that signal to
take effect and the thread to exit, the main thread can use
WaitForSingleObject, for one thread, or WaitForMultipleObjects, for several
threads, waiting in each case on the thread handle returned from
CreateThread (these are all P/Invoke names, of course).
Paul T.
"robvon" <robvon@austarnet.com.au> wrote in message
news:B15F7FB9-AABD-4AC7-A52C-465B89E722ED@microsoft.com...
> Peter Foot in his reply noted that a common problem with CF is to close
the form with threads still running. I have the same problem and I'm looking
for a suitable 'generic' way of dealing with this issue as the CF does not
seem to allow you to kill these threads unconditionally.
> For a progress form I use, I pass a form level variable which the forms
codes watches on each loop. So it terminates quite nicely when required.
> For async web service queries and also serial IO (OPENNETCF.io.serial) I
don't have an effective termination technique
> I need to:
> 1. Know which threads are active. In some cases I do know this
> 2. Have a communication method to tell them to die quetly. This is the
hard part
> 3. Wait until this death occurs
>
> In the good old days, a "death in the family" would bring down the
curtains. This one is a real pain.
>
> Any suggestions on top of my rather simple "form" solution appreciated
>
> BTW, I get rid of the program using PS and Kill on my WInCE device at the
command prompt. This may not be applicable on PPC.
>
> Rob von Nesselrode
> .NETCF Nobody
> Cairns, Australia