Re: BackgroundWorker in .NET CF 2.0
- From: "Daniel Moth" <dmoth74@xxxxxxxxxxx>
- Date: Sun, 10 Dec 2006 13:00:02 -0000
You have to be a bit more precise with your description.
"kill" an application, how? If it is just through the OK button then you are not killing, it you are closing it, which is fine.
It sounds like your ShutDown method isn't really getting rid of the threads. How are you trying to do that? If the thread is blocked on something you will have to design a mechanism to *ask* the thread to terminate. An example of how to use windows events to signal to a thread to terminate is here:
http://www.danielmoth.com/Blog/2004/11/dont-poll.html
Note that ThreadPool threads are not meant to be used for long running tasks or for blocking operations. For that, you should use a dedicated thread. Unless you are running against v1.0 of the NETCF where the pool has 256 rather than 25 (or you are on v2.0 but have tweaked the maximum).
It sounds like you are using the running programs list on the device to tell if your app is running. That is not god enough as it only shows the top level windows with a caption. Use the Remote Process Viewer from the Remote Tools menu under the Visual Studio menu from your Start menu. Then you can tell for sure if your app has exited or not.
Cheers
Daniel
--
http://www.danielmoth.com/Blog/
"davis" <davisford@xxxxxxxxx> wrote in message news:1165728211.815824.117500@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Chris, Thanks for the response.
Quick follow-up question...I'm not a wizard with this...still learning.
I tried using a thread pool to get the job done.
So, I have the method like this:
private void initDebug(object state) {
/* init debug TCP console here */
}
and in the main form constructor I have:
ThreadPool.QueueUserWorkItem(initDebug);
This seems to work ok...however when I kill the application, and I try
to re-deploy, I notice that it fails because the DLL i use for tcp
debug is in use.
I learned the hard way about the MinimizeBox property on CF forms. So,
I set this property to false, and I override the OnClosing method with
this:
protected override void OnClosing(CancelEventArgs e) {
e.Cancel = ShutDown( );
base.OnClosing(e);
}
where ShutDown( ) is my own method that tries to dispose of all
threads, sockets, etc.
It catches any exceptions and returns false if caught, otherwise it
returns true.
So, when I close the application, I see that the process is not listed
in the running processes on the PocketPc, but still, something has a
hold on this DLL, which leads me to have to reboot the device every
time.
Any ideas on what I'm doing wrong here?
Thanks in advance,
davis
<ctacke/> wrote:Create a thread. It's really not difficult. But there's also the SDF:
http://www.opennetcf.com/library/sdf/OpenNETCF.ComponentModel.BackgroundWorkerMembers.html
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
"davis" <davisford@xxxxxxxxx> wrote in message
news:1165721904.112835.165860@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi, I guess there is no BackgroundWorker in CF 2.0, but is there some
> other easy way to launch a quick background thread task from the UI?
>
> I have a debug console logger, and it takes a while to fire up and
> connect to a remote TCP server...and when it starts up, it causes
> program start lag.
>
> I could --
>
> a) Add a UI control to initialize it
> b) Spawn a new Thread(ThreadStart(initLogger));
>
> Is there a better way?
>
.
- Follow-Ups:
- Re: BackgroundWorker in .NET CF 2.0
- From: davis
- Re: BackgroundWorker in .NET CF 2.0
- References:
- BackgroundWorker in .NET CF 2.0
- From: davis
- Re: BackgroundWorker in .NET CF 2.0
- From: <ctacke/>
- Re: BackgroundWorker in .NET CF 2.0
- From: davis
- BackgroundWorker in .NET CF 2.0
- Prev by Date: Re: BackgroundWorker in .NET CF 2.0
- Next by Date: Re: BackgroundWorker in .NET CF 2.0
- Previous by thread: Re: BackgroundWorker in .NET CF 2.0
- Next by thread: Re: BackgroundWorker in .NET CF 2.0
- Index(es):
Relevant Pages
|