Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7940157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:18:22+00:00 2026-06-03T23:18:22+00:00

I have a user control where i registered idle event under Load event of

  • 0

I have a user control where i registered idle event under Load event of that control.

Control_Load(object sender, System.EventArgs e)
{
    Application.Idle += new EventHandler(Application_Idle);
}

I know this will trigger when application finishes processing and reached idle state.But i really confused what is application here which goes idle, does that this usercontrol where load event register the idle event handler.When i put breakpoint every time it hits, what does this means?

For example i created a Form which contains this code

int counter = 0;
private void Form1_Idle(object sender, System.EventArgs e)
{
    counter++;
    label1.Text = counter.ToString();
}

private void Form1_Load(object sender, System.EventArgs e)
{
    Application.Idle +=new EventHandler(Form1_Idle);
}

then i create some buttens in that form which has certain operations to do.As per my understading label counter should not increase when i am doing operations through the buttons i created because its not in idle state, but now what happens is even some operation going on by clicking button lable counter is increasing, except if i press form title bar and move the form around.

One more thing do i need to detach these event handler when close my window even if this is main application window. If so if i do in dispose method will that sufficient?

protected override void Dispose(bool disposing)

UPDATE
if i am pressing some text through keyboard say “LARSEN” ,between the press of alphabet “L” and “A” does idle event occurs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:18:23+00:00Added an answer on June 3, 2026 at 11:18 pm

    It triggers every time when it have processed all the messages and there are no messages left. As for disposing, per MSDN “Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result.” – so I guess detaching it on form dispose (or probably on form close if its handler has something to do with the form) is enough.

    upd: message loop is started in your Program.cs like this:

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
    

    It processes all the messages like mouse move, key pressed and lots and lots more. You probably should read in length about it somewhere, possibly a book, but yes, there is an “idle” state after your first keypress is processed, long before you hit second key.

    upd2: If you want to detect “real idle” you might want to start (and re-start) some sort of timer in this handler and when it expires maybe check CPU load or some such, depending on exact desired condition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control that takes a several seconds to load. Is there
I have a .NET user control registered as COM. I use regasm to register
I have a user control that has a few public properties, one is an
I have a user control that I've created, however when I go to add
I have a user control with a More Info link. When clicking that link,
I have a user control that contains a collection of controls to be reused
I have a Silverlight user control that contains an ItemsControl that renders a StackPanel
I have a Win32 application that includes an EXE, an ActiveX control (DLL) and
I have a user control: <%@ Control Language=C# AutoEventWireup=true CodeBehind=Autocomplite.ascx.cs Inherits=Application.Controls.Autocomplite %> <script type=text/javascript
I have a user control, a dropdown list, that's comprised of many component controls.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.