473,395 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.Thread(New Threading.ThreadStart(AddressOf
ShowMessage))
t.IsBackground = True
t.Start()
System.Threading.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 7091
You can use the Timer control in a Win Form or use system.Timers.Timer.

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.Timer.

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="This is the message"
frm.MsgDisplayLength=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*****@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.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.Timer.

Dec 31 '05 #4
"genojoe" <ge*****@discussions.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.Thread(New Threading.ThreadStart(AddressOf
ShowMessage))
t.IsBackground = True
t.Start()
System.Threading.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*****@discussions.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=custommsgbox&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*******@freenet.de> wrote in message
news:eU**************@TK2MSFTNGP12.phx.gbl...
"genojoe" <ge*****@discussions.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.Thread(New Threading.ThreadStart(AddressOf
ShowMessage))
t.IsBackground = True
t.Start()
System.Threading.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
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...
2
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...
2
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...
5
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...
6
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...
1
by: ad | last post by:
I want show some message to user when his session time out. How can I do that?
2
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...
10
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.