Re: BackgroundWorker in .NET CF 2.0

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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?
>


.



Relevant Pages

  • Re: Remove shutdown in remote desktop
    ... shutdown option when they connect to their workstations at the office." ... I did do a remote ... Shutdown inside of it. ... Remote Desktop session I'm not aware of a way to accomplish that so that it ...
    (microsoft.public.windows.server.sbs)
  • Re: reboot problem
    ... if you can vpn the lan, you may have many options to shutdown it remotely. ... How to Setup Windows, Network, Remote Access on http://www.HowToNetworking.com ... Networking, Internet, Routing, VPN Troubleshooting on http://www.ChicagoTech.net ... system from TS my session ends but the server never restarts. ...
    (microsoft.public.windows.terminal_services)
  • Re: Block windows remote shutdown command on a domain
    ... This is done in Group Policies, Computer Configuration, Windows Settings, Security Settings, Local Policies, User Rights Assignments ... Force Shutdown from a remote system. ...
    (microsoft.public.windowsxp.security_admin)
  • RE: total newbie question
    ... As you said "Remote shutdown or anything else it ... I can trade files very easily, I have established a Internet connection ... Both Say I have Admin Rights But when I try to use ...
    (microsoft.public.windowsxp.work_remotely)
  • Re: How to force user log off
    ... scripting is not your forte) take advantage of Shutdown Windows ... "Jorge Silva" wrote: ... remotely using Remote Administration console (assuming that the computer ... talk to the guy and let him know that his account is no longer for use ...
    (microsoft.public.windows.server.active_directory)