473,806 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using End

Bob
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.T imer
Private frm As Form

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

Private DoingMessage As Boolean

Private Sub tmr_Tick(ByVal sender As Object, ByVal e As
System.EventArg s) 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.OKC ancel) = MsgBoxResult.OK Then
End
End If
DoingMessage = False
End If
End Sub

End Module
Nov 21 '05 #1
5 1223
I will use Application.Exi t Method.
Nov 21 '05 #2

"Bob" <no***@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
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.


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
Nov 21 '05 #3
"Rulin Hong" <Ru*******@disc ussions.microso ft.com> schrieb:
I will use Application.Exi t Method.


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

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

Nov 21 '05 #4
Bob
"Larry Serflaten" <se*******@usin ternet.com> wrote in message
news:OX******** ******@TK2MSFTN GP15.phx.gbl...
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


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
Nov 21 '05 #5
environment.exi t

Never failed me before.

Is it nice ? Probably not.
Does it kill everything? Yes.
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5721
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ================================================================= Error 19: "CORBAManagerMessages.h", line 4 # Unexpected 'std'. using std::string; ^^^
3
2167
by: Mike L | last post by:
Should the command call "using" be before or after my namespace? **AFTER** namespace DataGridBrowser { using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Collections;
3
2445
by: xzzy | last post by:
I was wondering why we have to have using System.Data using System.Configuration using etc.... why are they not all lumped into one 'using'? In other words, is there a best way to use project classes with 'using' meaning
14
5808
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the SQL DATABASE, probably by the click of a button. Is this possible? & what is the BEST APPROACH for doing this? & also if any links are there do tell those to me too coz I have no idea how to go about doing it.
8
2416
by: acb | last post by:
Hi, I wrote a DLL Component (using Visual Studio 2005) and managed to include it into a C# Console application. I am now trying to include this component into a Web project. I copy the DLL into the bin directory but am not able to progress. Can anyone please guide me to an online tutorial on the subject. Thanks,
0
2210
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase .NET 2.0 DataProvider (iAnywhere.Data.AsaClient.dll) into the GAC so it can be used in the ProviderName property of a SQLDataSource and loads properly at run time. The application I'm writing is a bit more complex than the example I'm about to...
10
1976
by: mg | last post by:
I'm migrating from VB6 and have a question about using 'Using' and the best way to use it. Here is a example of a small bit of code: dbConx("open") Using CN Dim CMD As New OleDbCommand(sSQL, CN) Dim DR As OleDbDataReader = CMD.ExecuteReader()
0
2579
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation link (1,2,3 so on). The code can be found in SubscriptionCart.aspx.cs. Default.aspx ------------
3
8305
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0 build with these methods, will appear to encrypt and decrypt, but the resulting decrypted file will be corrupted. I tried encrypting a .bmp file and then decrypting, the resulting decrypted file under .NET 2.0 is garbage, the .NET 1.1 build works...
6
5177
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick application working. However, when attempting to implement the solution, the AJAX calls weren't updating the screen like the examples were and seemed not to fire until after the long running process had completed. I found the only real...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10618
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.