473,396 Members | 2,109 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,396 software developers and data experts.

Timer problem

I am trying to use the timer to make a login form show after a specified
interval. However, if the interval is set to a value greater than 5000
nanosecond, then it does not respond. What could be the issue here? Thanks.
private void frmMain_Load(object sender, EventArgs e)
{
this.timer = new Timer();
this.timer.Interval = 25000;
this.timer.Tick += new EventHandler(this.timer_Tick);
Application.Idle += new EventHandler(this.Application_Idle);

}

void Application_Idle(object sender, EventArgs e)

{
this.timer.Stop();
this.timer.Start();
}

void timer_Tick(object sender, EventArgs e)

{
frmLogin form = new frmLogin();
form.ShowDialog();
}
--
L. A. Jones
--
L. A. Jones
Nov 3 '07 #1
3 2449
On 2007-11-03 12:31:00 -0700, Dave <Da**@discussions.microsoft.comsaid:
I am trying to use the timer to make a login form show after a specified
interval. However, if the interval is set to a value greater than 5000
nanosecond, then it does not respond. What could be the issue here? Thanks.
First, you can't specify a "5000 nanosecond" timer delay. The timer
interval is in milliseconds (thousandths of a second).

Secondly, did you check to see whether the Application.Idle event is
being raised multiple times? You ask "what could be the issue here?"
and the obvious answer is that if the Idle event is raised before the
timer expires, then you reset the timer and start all over, never
allowing the timer interval to expire.

I haven't bothered to test the code you posted, but just looking at it,
the Idle event seems like the most likely culprit.

I also find it interesting that with the design you've chosen, your
login dialog could pop up even after the application is no longer idle
again. You don't bother to stop the timer until the next time the Idle
event is raised, so if you've started the timer and it expires before
the application reaches the idle state again, the Tick event will be
raised and cause the login dialog to be shown, even though the
application hasn't been idle.

Pete

Nov 3 '07 #2
I have not found a suitable way to get this done. I'm googling to find a
solution.
--
L. A. Jones
"Dave" wrote:
I am trying to use the timer to make a login form show after a specified
interval. However, if the interval is set to a value greater than 5000
nanosecond, then it does not respond. What could be the issue here? Thanks.
private void frmMain_Load(object sender, EventArgs e)
{
this.timer = new Timer();
this.timer.Interval = 25000;
this.timer.Tick += new EventHandler(this.timer_Tick);
Application.Idle += new EventHandler(this.Application_Idle);

}

void Application_Idle(object sender, EventArgs e)

{
this.timer.Stop();
this.timer.Start();
}

void timer_Tick(object sender, EventArgs e)

{
frmLogin form = new frmLogin();
form.ShowDialog();
}
--
L. A. Jones
--
L. A. Jones
Nov 3 '07 #3
I suggest that Peter's help is better than you will find via Google.

Your idle event is starting the timer. You are getting an idle event any
time app is waiting, which I'm guessing, is most of the time your app is
running. I believe if you want your app to show the dialog every interval,
you don't want the idle event handler. Is it possible you are trying to get
the time that the user has been idle and not the application? I'm sure
screensavers use something along those lines and you should follow suit.

"Dave" wrote:
I have not found a suitable way to get this done. I'm googling to find a
solution.
--
L. A. Jones
"Dave" wrote:
I am trying to use the timer to make a login form show after a specified
interval. However, if the interval is set to a value greater than 5000
nanosecond, then it does not respond. What could be the issue here? Thanks.
private void frmMain_Load(object sender, EventArgs e)
{
this.timer = new Timer();
this.timer.Interval = 25000;
this.timer.Tick += new EventHandler(this.timer_Tick);
Application.Idle += new EventHandler(this.Application_Idle);

}

void Application_Idle(object sender, EventArgs e)

{
this.timer.Stop();
this.timer.Start();
}

void timer_Tick(object sender, EventArgs e)

{
frmLogin form = new frmLogin();
form.ShowDialog();
}
--
L. A. Jones
--
L. A. Jones
Nov 4 '07 #4

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

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
11
by: Steve Jorgensen | last post by:
I've recently been playing with some UI ideas that require the user of a timer to drive animation. The problem I'm having is that Access routinely stops firing timer events for long periods of...
9
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null;...
4
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts...
4
by: Daniel | last post by:
Hey guys Here is what i want to do. I have made a multiplayer game that needs to when more than one player is ready start a countdown that the clients can see, so players can still join in this...
4
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this...
8
by: KnighT | last post by:
I have a .net service that runs a System.Threading.Timer. The delegate points to the function that the service should execute when the timer elapses. Problem: The timer is not ticking. I have...
8
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next...
16
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not...
2
by: Johnny Jörgensen | last post by:
I've got a process I want to run in a thread separate from my main application thread, so I've used a backgroundworker component, and in frmMain.Load I invoke the code using...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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.