You must Sign In to post a response.
  • Category: Windows

    Check idle time in c# winforms

    Dear Friends.,

    i have a tool in c# windows application, it can pick data from sql for every 10 seconds. i need to check idle time of this application.
  • #765476
    You have to use the timer and there is one dll that you have to use that is user32.dll and you have to include the name space System.RunTime.Interopservices.
    SRI RAMA PHANI BHUSHAN KAMBHAMPATI

  • #765478
    what you mean by check idle time ? there is no idle time concept exist for winform applications. what you want to do exactly ? Please elaborate
    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #765506
    @Prasad,

    There is a concept of Idle time.
    whenever your computer is Idle and user sleeping in front of computer without moving the mouse than the Idle time of computer will be calculated.

    SRI RAMA PHANI BHUSHAN KAMBHAMPATI

  • #765532
    Hi,
    1) Add a timer.
    2) Inside that timer invoke GetLastInputInfo() method which returns the number in millisecond since last input was detected from the user.
    3) Find GetLastInputInfo() method code over here:
    http://www.pinvoke.net/default.aspx/user32.GetLastInputInfo

  • #765533
    1. Add the timer control in your form
    2. Have one global variable to measure the ideal time
    3. In the timer start the initialize the value.
    4. When the window become de-active start timer.
    5. Once the window active read the variable and store in DB/show in alert box

    By Nathan
    Direction is important than speed


Sign In to post your comments