Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
GeneralRe: Pausing execution for certain amount of time without freezing the form. Pin
Luc Pattyn3-Mar-11 0:53
sitebuilderLuc Pattyn3-Mar-11 0:53 
AnswerRe: Pausing execution for certain amount of time without freezing the form. Pin
musefan2-Mar-11 22:20
musefan2-Mar-11 22:20 
QuestionConsole in c# 2008 Express Pin
Bob Pawley2-Mar-11 12:47
Bob Pawley2-Mar-11 12:47 
AnswerRe: Console in c# 2008 Express Pin
Dave Kreskowiak2-Mar-11 12:59
mveDave Kreskowiak2-Mar-11 12:59 
AnswerRe: Console in c# 2008 Express Pin
DaveyM692-Mar-11 13:32
professionalDaveyM692-Mar-11 13:32 
AnswerRe: Console in c# 2008 Express Pin
I Believe In GOD2-Mar-11 21:16
I Believe In GOD2-Mar-11 21:16 
QuestionHow to select a radio button in internet explorer. Pin
sososm2-Mar-11 11:46
sososm2-Mar-11 11:46 
QuestionLastinputinfo() not working on my machine ... Pin
turbosupramk32-Mar-11 10:51
turbosupramk32-Mar-11 10:51 
For some reason this will not work on my machine (Vista Enterprise sp2)

My messagebox display says "697538 seconds 697538 (this increments each time I run it but is always the same as the first number) seconds At second 0" .

When I run the second block of code it says "Last input ticks is 8 and idle ticks is 697791247 (this increments each time I run it) .

I got code example from this site, any idea as to why this won't work for me or what I am doing wrong? Thank you for reading.


http://www.geekpedia.com/tutorial210_Retrieving-the-Operating-System-Idle-Time-Uptime-and-Last-Input-Time.html[^]


public static void timerThread()
{
    int timerCount = 0;
    //int LastInputTicks = 0;
    //int IdleTicks = 0;
    while (true)
    {
        MessageBox.Show("Start counting");
        Thread.Sleep(10000);
        int systemUptime = Environment.TickCount;
        int LastInputTicks = 0;
        int IdleTicks = 0;
        LASTINPUTINFO LastInputInfo = new LASTINPUTINFO();
        LastInputInfo.cbSize = (uint)Marshal.SizeOf(LastInputInfo);
        LastInputInfo.dwTime = 0;
        LastInputTicks = (int)LastInputInfo.dwTime;
        IdleTicks = systemUptime - LastInputTicks;
        string one = Convert.ToString(systemUptime / 1000) + " seconds";
        string two = Convert.ToString(IdleTicks / 1000) + " seconds";
        string three = "At second " + Convert.ToString(LastInputTicks / 1000);
        MessageBox.Show(one + " " + two + " " + three);
        Thread.Sleep(60000);
    }

}




public static void timerThread()
{
    int timerCount = 0;
    int LastInputTicks = 0;
    int IdleTicks = 0;
    while (true)
    {
        MessageBox.Show("Start counting");
        Thread.Sleep(10000);
        int systemUptime = Environment.TickCount;
        LASTINPUTINFO lastInPut = new LASTINPUTINFO();
        lastInPut.dwTime = 0;
        lastInPut.cbSize = (uint)Marshal.SizeOf(lastInPut);
        lastInPut.dwTime = (uint)Marshal.SizeOf(lastInPut);
        LastInputTicks = (int)lastInPut.dwTime;
        IdleTicks = systemUptime - LastInputTicks;
        MessageBox.Show("Last input ticks is " + LastInputTicks.ToString() + " and idle ticks is " + IdleTicks.ToString());
        Thread.Sleep(60000);
    }

}

AnswerRe: Lastinputinfo() not working on my machine ... Pin
Eddy Vluggen2-Mar-11 11:08
professionalEddy Vluggen2-Mar-11 11:08 
AnswerRe: Lastinputinfo() not working on my machine ... [modified] Pin
DaveyM692-Mar-11 12:11
professionalDaveyM692-Mar-11 12:11 
GeneralRe: Lastinputinfo() not working on my machine ... Pin
turbosupramk33-Mar-11 6:08
turbosupramk33-Mar-11 6:08 
GeneralRe: Lastinputinfo() not working on my machine ... Pin
DaveyM693-Mar-11 6:58
professionalDaveyM693-Mar-11 6:58 
QuestionGetting the relevent letter for unicode. Pin
prasadbuddhika2-Mar-11 6:46
prasadbuddhika2-Mar-11 6:46 
AnswerRe: Getting the relevent letter for unicode. Pin
Richard MacCutchan2-Mar-11 6:55
mveRichard MacCutchan2-Mar-11 6:55 
AnswerRe: Getting the relevent letter for unicode. Pin
Eddy Vluggen2-Mar-11 7:24
professionalEddy Vluggen2-Mar-11 7:24 
GeneralC# / WPF Job Offer in Tampa, FL Pin
Azad Giordano Ratzki2-Mar-11 4:13
professionalAzad Giordano Ratzki2-Mar-11 4:13 
GeneralRe: C# / WPF Job Offer in Tampa, FL Pin
Pete O'Hanlon2-Mar-11 4:23
mvePete O'Hanlon2-Mar-11 4:23 
GeneralRe: C# / WPF Job Offer in Tampa, FL Pin
Azad Giordano Ratzki2-Mar-11 4:30
professionalAzad Giordano Ratzki2-Mar-11 4:30 
GeneralRe: C# / WPF Job Offer in Tampa, FL Pin
Pete O'Hanlon2-Mar-11 4:46
mvePete O'Hanlon2-Mar-11 4:46 
GeneralRe: C# / WPF Job Offer in Tampa, FL Pin
Pete O'Hanlon2-Mar-11 5:39
mvePete O'Hanlon2-Mar-11 5:39 
GeneralRe: C# / WPF Job Offer in Tampa, FL Pin
Dan Mos2-Mar-11 5:47
Dan Mos2-Mar-11 5:47 
GeneralRe: C# / WPF Job Offer in Tampa, FL Pin
I Believe In GOD2-Mar-11 5:54
I Believe In GOD2-Mar-11 5:54 
GeneralRe: C# / WPF Job Offer in Tampa, FL Pin
Pete O'Hanlon2-Mar-11 7:23
mvePete O'Hanlon2-Mar-11 7:23 
GeneralRe: C# / WPF Job Offer in Tampa, FL Pin
R. Giskard Reventlov2-Mar-11 5:17
R. Giskard Reventlov2-Mar-11 5:17 
GeneralRe: C# / WPF Job Offer in Tampa, FL Pin
Azad Giordano Ratzki2-Mar-11 5:30
professionalAzad Giordano Ratzki2-Mar-11 5:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.