Soft reset required

H

Harry Simpson

Why would my app need a soft reset sometimes to start again. I'm stopping
my barcode reader component in the OnClosing event which fires when the OK
is pressed.
I verify that the program is not running but trying to click the icon to
start it doesn't work at all unless i reset the device.

How can i trouble shoot this.....there's no taskmanager as in Win32
apps....?

Harry
 
C

Chance Hopkins

Harry Simpson said:
Why would my app need a soft reset sometimes to start again. I'm stopping
my barcode reader component in the OnClosing event which fires when the OK
is pressed.
I verify that the program is not running but trying to click the icon to
start it doesn't work at all unless i reset the device.

How can i trouble shoot this.....there's no taskmanager as in Win32
apps....?

This might help with part of your inquiry:

http://www.phm.lu/Products/PocketPC/TaskMgr/
 
C

Chris Tacke, eMVP

My bet is that you spawn a worker thread that you're not always killing.
When you try to re-run the app, it sees that it is already running and fails
to laod a new instance. Make sure you actually kill any worker thread you
start before exiting the app.
 
H

Harry Simpson

Thanks Chris and Chance,

That's what I suspected too but other than the barcode scan i couldn't think
of anything else other than an open SQLCE connection or something. What
other kindof worker threads should i look for?

In the OnClosing I do the following:
Protected Overrides Sub OnClosing(ByVal e As
System.ComponentModel.CancelEventArgs)
BarcodeReader1.Stop()
End Sub

Is there anything I can do here to issue a blanket process close that would
clean up adequately?

TIA
Harry
 
S

Sergey Bogdanov

On the closing event you may set a breakpoint and you will see all your
running threads in the Threads windows (press Ctrl + Alt + H in debug
mode). If one of this thread will stay alive your process will not be
terminated.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
H

Harry Simpson

Article ranked pitiful by the readers.....There really must be a threads
collection to iterate through rather that this method.

HArry
 
C

Chris Tacke, eMVP

There is no Threads collection. If you want one you must create it or use
the toolhelp APIs (the SDF has a full set of wrappers)
 
C

Chance Hopkins

With the exception of this small error (I think the comments are backwards
below), I thought it got the job done.

I actually just multithreaded my app and didn't even realise the problem you
brought up existed. I've fixed the behaviour with the information in the
article, so personnaly I'd have to recommend it. I can now shut down my app
with two threads running and start it again without any problems. I'm now
where you want to be, so read the article. You can create your own array of
threads if you'd like, it will just take some elbow grease. Good luck.


if anyone from ms is reading. these two comments are backwards on that page
(the code itself works fine)

if (this.numThreads > 0)
{
// If there are no secondary threads running then shut down
// the application
e.Cancel = true;
this.OutputLabel.Text = String.Format("Closing Thread {0}",
this.numThreads + 1);
}
else
{
// If there are secondary threads running then cancel
// the application shutdown
e.Cancel = false;
this.OutputLabel.Text = "Closing Main Thread";
}
 

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