Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check how long my application was open? 1

Status
Not open for further replies.

Plato2

Programmer
Dec 6, 2002
192
0
0
US
I want to check how long my application was open.And if it was open a certain period of time , i need to call a certain function.

Thanks in advance
 
Use DateTime.Now when it starts, then call DateTime.Now when it ends, then subtract the two values (giving you a TimeSpan object).

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
You don't need to store the start time, use the following at any time and it will give you the uptime of your application.
Code:
Dim ts As TimeSpan = DateTime.op_Subtraction(DateTime.Now, System.Diagnostics.Process.GetCurrentProcess.StartTime)

Console.WriteLine("Application running for {0} hours, {1} minutes, {2} seconds", ts.Hours, ts.Minutes, ts.Seconds)
 
SHelton,
How do you past you code in like that?
 
Thanks a lot that what I'm looking for
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top