473,651 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Show a timed message

To my surprise, I could not find an easy way to show a timed message with
either MessageBox() or MsgBox(). Here is some code that I tried
unsuccessfully:

Dim t As New Threading.Threa d(New Threading.Threa dStart(AddressO f
ShowMessage))
t.IsBackground = True
t.Start()
System.Threadin g.Thread.Sleep( 5000)
t.Abort()
=============== =========
Private Sub ShowMessage()
MessageBox.Show ("This message is displayed for 5 seconds")
End Sub

My Internet searches were not successful. There must be an easy way to do
this.

Dec 30 '05 #1
6 7150
You can use the Timer control in a Win Form or use system.Timers.T imer.

Dec 30 '05 #2
I do not understand what you mean. I know how to use a timer to start
something like displaying a message or updating a database but once I open a
Message box, I do not know how to use a timer to force the message to close.

Can you provide an example?

"Brad Roberts" wrote:
You can use the Timer control in a Win Form or use system.Timers.T imer.

Dec 31 '05 #3
Best method is to create a form for the message... Turn off the
control-box in the properties so it looks like a popup and set for "Fixed
Dialog".

Put a label in the middle of the form and a timer.

Then expose 2 properties and a function. Property 1 is a string called
MsgText, Property 2 is the length of time (in ms) to display. The function
is called display.

The function sets the timer interval to the length, the label text to the
MsgText and then does a me.showdialog..

If the timer.tick event just do a me.close to close the form.

To call the popup just instanciate the form, set the 2 properties and then
call the Display function.. ie

dim frm as new popupmessage
frm.MsgText="Th is is the message"
frm.MsgDisplayL ength=5000
frm.display
frm.dispose

If you want to get advanced then wrap the whole lot up in a class.

Hope this helps
Simon

"genojoe" <ge*****@discus sions.microsoft .com> wrote in message
news:33******** *************** ***********@mic rosoft.com...
I do not understand what you mean. I know how to use a timer to start
something like displaying a message or updating a database but once I open
a
Message box, I do not know how to use a timer to force the message to
close.

Can you provide an example?

"Brad Roberts" wrote:
You can use the Timer control in a Win Form or use system.Timers.T imer.

Dec 31 '05 #4
"genojoe" <ge*****@discus sions.microsoft .com> schrieb
To my surprise, I could not find an easy way to show a timed message
with either MessageBox() or MsgBox(). Here is some code that I
tried unsuccessfully:

Dim t As New Threading.Threa d(New Threading.Threa dStart(AddressO f
ShowMessage))
t.IsBackground = True
t.Start()
System.Threadin g.Thread.Sleep( 5000)
t.Abort()
=============== =========
Private Sub ShowMessage()
MessageBox.Show ("This message is displayed for 5 seconds")
End Sub

My Internet searches were not successful. There must be an easy way
to do this.


I recommend not to abort a thread this way. I admit I don't know why it
doesn't work this way. It's better to perform a controlled end of a thread.
Create your own Form instead and call it's Close method to close it (Invoke
required).
Armin

Dec 31 '05 #5
"genojoe" <ge*****@discus sions.microsoft .com> schrieb:
To my surprise, I could not find an easy way to show a timed message with
either MessageBox() or MsgBox().


You may want to roll your own message box function:

Implementing a message box with standard behavior
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=custommsgbo x&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 31 '05 #6
"Armin Zingler" <az*******@free net.de> wrote in message
news:eU******** ******@TK2MSFTN GP12.phx.gbl...
"genojoe" <ge*****@discus sions.microsoft .com> schrieb
To my surprise, I could not find an easy way to show a timed message
with either MessageBox() or MsgBox(). Here is some code that I
tried unsuccessfully:

Dim t As New Threading.Threa d(New Threading.Threa dStart(AddressO f
ShowMessage))
t.IsBackground = True
t.Start()
System.Threadin g.Thread.Sleep( 5000)
t.Abort()
=============== =========
Private Sub ShowMessage()
MessageBox.Show ("This message is displayed for 5 seconds")
End Sub

My Internet searches were not successful. There must be an easy way
to do this.


I'm a bit curious why you are using a separate thread instead of just
placing a timer control on your form and using it's procedures to turn your
message on or off?

Regards
Mike Enarson
Jan 2 '06 #7

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

Similar topics

2
3917
by: Andy | last post by:
Hi Gang Is there any way with ASP that I can tell if a user session has timed out? The problem is that we have a database app where a user session may time out. After this happens the user may try to save the data that is on there screen (without knowing they've timed out). I think what happens then (after the save) is that we get zero's in some of the fields in the database because the session has timed out.
2
1628
by: Javaman59 | last post by:
I have a GUI which is monitoring a real-time device. I have several timed actions, such as periodic polling of the device, and indicators which flash for a fixed period. My first implementation of this was to replicate the way I have seen this done before - have one central timed method, which is on a timer tick, and use time variables to keep track of when events are due. I have now realized that I can avoid the timer method, and time...
2
7856
by: William F. Robertson, Jr. | last post by:
Some of my users are receiving an error: Server Error in '/' Application. ---------------------------------------------------------------------------- ---- Request timed out. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
5
9022
by: Sachin Surana | last post by:
We use HttpWebRequest to send the request at a URL. But some times the method GetResponse throws a time out exception. But when we check the IIS logs, there is no such entry. So the request never reached the server but the client is getting a time out exception. What could be the possible reasons? Confirmed that the request does not get lost in the network.
6
3782
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for one day): \\FFDS24\ASP.NET Applications(_LM_W3SVC_1_Root_ATV2004)\Errors During Execution: 7 \\FFDS24\ASP.NET Apps v1.1.4322(_LM_W3SVC_1_Root_ATV2004)\Compilations
1
1574
by: ad | last post by:
I want show some message to user when his session time out. How can I do that?
2
25458
by: tlan | last post by:
Hi, I got this error when I move my web service to Windows2003 server. I spent hours scouting on the internet and could find any answer. Please help!!! I the webservice is timeout between 1 -2 minutes when my web app, which consume this webService, retrieves a large amount of data. When I perform the same operation to retrieve smaller amount of data, it works fine. The timeout value I set for my web app, web service, and sql
10
19142
by: Jim Underwood | last post by:
I am having a problem with my web page timng out while retrieving a long runnign report (90-120 seconds. I have tried modifying several settings in various places and cannot get it to run for more than 90 seconds. I am running VS.Net and the app is ASP.Net, written using VB.Net. The app calls an asp.Net web service to retrieve the report. Both the web site and the web service are running locally on my PC. I have tried modifying the...
1
1633
by: GabrielESandoval | last post by:
I am converting powerepoint presentations to images I want to display as slide shows. My questions is I want it so that when a link is clike the slide show opens. The slides will be initially timed but there are also controls so that if they want to go back or advance the images at their own pace. Is this too complicated?? I know how to make a slow that displays images ina times sequence, but Ive never added controls that would stop...
0
8349
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8275
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
8795
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
8695
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
8576
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...
1
6157
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2696
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
1
1906
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.