Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

Using End

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 28 Oct 2004 22:12 GMT
My app shows a modal MDI parent form, and creates a timer that ticks every
ten minutes to boot unresposive users at 3 in the morning. Below is a
simplified working example with no time check. My question is, is it OK to
use End or it is there a cleaner way to close the app? Keep in mind that I
want everything taken down, including any warning dialogue box shown from
the timer, and any others that happen to be still open in the MDI parent
itself - so frm.Close does not work.

TIA,
Bob

'---------------------------------
Module Main

   Private WithEvents tmr As Windows.Forms.Timer
   Private frm As Form

   Public Sub Main()
       tmr = New Timer
       tmr.Interval = 2000
       tmr.Enabled = True
       frm = New Form
       frm.WindowState = FormWindowState.Maximized
       frm.IsMdiContainer = True
       frm.ShowDialog()
   End Sub

   Private DoingMessage As Boolean

   Private Sub tmr_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tmr.Tick
       If DoingMessage Then
           Beep()
           End
       Else
           Dim msg As String = "This application will now shut down for the
night."
           DoingMessage = True
           If MsgBox(msg, MsgBoxStyle.OKCancel) = MsgBoxResult.OK Then
               End
           End If
           DoingMessage = False
       End If
   End Sub

End Module
Rulin Hong - 28 Oct 2004 22:25 GMT
I will use Application.Exit Method.
Herfried K. Wagner [MVP] - 29 Oct 2004 11:19 GMT
"Rulin Hong" <RulinHong@discussions.microsoft.com> schrieb:
>I will use Application.Exit Method.

This method will work similar to 'End'.  I would try to avoid using both of
these methods and close the main form instead.

Signature

Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/

jela - 29 Oct 2004 22:04 GMT
environment.exit

Never failed me before.

Is it nice ? Probably not.
Does it kill everything? Yes.
Larry Serflaten - 29 Oct 2004 02:47 GMT
"Bob" <noone@nowhere.com> wrote
> My app shows a modal MDI parent form, and creates a timer that ticks every
> ten minutes to boot unresposive users at 3 in the morning. Below is a
[quoted text clipped - 3 lines]
> the timer, and any others that happen to be still open in the MDI parent
> itself - so frm.Close does not work.

It could work, if you designed it to work....

You could create a class whose sole responsibility is to raise a ShutDown
event and have all your forms listen for that event and close themselves down
(gracefully) when it happens.  It may mean you have to create your own
MessageBox to display messages, but the 15 minutes you might use to do
that will provide you with a proactive means to be sure everything closes.
(Be aware you may not know which order the individual forms will recieve
that ShutDown event notification, so each form should just handle shutting
themselves down)

Instead of calling End, you could just send a call to that class to raise
the ShutDown event, and then exit out of the current sub.  With all forms
closed, and no code executing, your application should close in a nice
clean fashion.

LFS
Bob - 29 Oct 2004 14:28 GMT
> It could work, if you designed it to work....
>
[quoted text clipped - 13 lines]
>
> LFS

Um... hmmm.

Yes, even though it's 130MB of code (most of it forms designer bloat) with
both inputboxes and messageboxes, I suppose it wouldn't take too long to
search and replace all of these.

I just have to shake my head, though, I would have thought MS would have put
in a facility to close all an app's dialogues automatically by now. *shrug*

I think I'm going to dig around for a way to detect and kill all dialogues
first (exluding the main MDI form of course). I bet there's a way.

Bob

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.