Application.exit

  • Thread starter Thread starter Chuck Hecht
  • Start date Start date
C

Chuck Hecht

Hello all,
I have a command button on a form that serves as a exit for the application.
The only code in the button is Application.exit. At run time the button when
tapped locks the device and the form freezes. Any ideas??
Thank you

chuck
 
Have you got any other threads running?

Rather than calling Application.Exit, make sure all your other threads have
terminated and then close the main form.

Cheers
Daniel
 
Well, if only your application is launch, it is normal because when you type
your button exit (Application.Exit) your application stop refresh itself
because it is ended and as no other application form try to repaint itself,
you see your form and it sounds like freezes.
So i think it is normal, i have the same thing with my device..
If you launch the Explorer.exe, under your applicatiin, you will see your
application disapear..
Jérôme
 
Just use the System.Diagnostics.Process to launch explorer.exe. This
assumes you don't already have a shell running.

-Chris
 
Chuck,

If you need further help, please post here rather than directly emailing.
It allows the answer to potentially help others, plus I have a strict rule
on answering direct email because if I don't I get too much.

At any rate, if you're creating any worker threads (or creating objects that
create them) then you must ensure the workers are killed before exiting.
You don't give us much detail, like CF version, etc. so we can't offer much
more than that.

-Chris
 
Hi Chris

Sorry about the direct reply I clicked "Reply" not "Reply Group"

I am using VS2005 CF 2.0 The targeted device is a symbol PPT 8846 running
PPC 2003
I have the symbol SMDK(ver 1.1) installed

As I mentioned before the topic of threads has not been anyting that I have
been dealing with on
a routine basis.

****This is where I see 1 of the threads created

Public Function InitReader() As Boolean

If Not (Me.MyReader Is Nothing) Then
Return False
End If
Me.MyReader = New Symbol.Barcode.Reader
Me.MyReaderData = New Symbol.Barcode.ReaderData
Symbol.Barcode.ReaderDataTypes.Text, _
Symbol.Barcode.ReaderDataLengths.DefaultText)
Me.MyEventHandler = New System.EventHandler(AddressOf MyReader_ReadNotify)
****AddHandler Me.Activated, New EventHandler(AddressOf
frmMainForm_Activated)
AddHandler Me.Deactivate, New EventHandler(AddressOf frmMainForm_Deactivate)
Me.MyReader.Actions.Enable()
Return True
End Function

The other times occur when I call a function that pulls the serial number
from the device

Any help you can offer is greatly appreicated
Thanks again

chuck
 
I bet the barcode reader control spawns a separate thread. You should
destroy them before exiting, or better yet, exit the app the usual way by
closing the form instance passed to Application.Run.

-Chris
 
Yep, it's definitely a thread. Try explicitly destroying and Disposing (if
they expose it) all of the barcode objects when you close the form.

-Chris
 
Hi Chris

This is what I am doing

Application.run(frmMain)

I have 3 exit buttons (3 different panels)
each button contains

frmMain.close

The form closes and it appears that the app is gone but if I try to get back
in to the app nothing happens it will not start and I need to soft reset the
device.

chuck
 
Hi,

You should have code like this:

Me.BarcodeReader1.Stop()

Me.BarcodeReader1.Dispose()

Me.Close()

or replace Me with this and add semicolons (C#).

Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
Back
Top