Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a C# app track how long its been running?

Tags:

c#

.net

And if it does, is there an easy way to get the total time since it started?

like image 822
broke Avatar asked Jul 03 '12 19:07

broke


People also ask

Does AC actually cool the air?

Removing heat from the air Believe it or not, creating “cold” isn't actually a thing. Cold is just how we describe a lack of thermal heat. Your air conditioner does not “create” cold air, it removes heat from warm air.

How does a AC work?

As the liquid refrigerant inside the evaporator coil converts to gas, heat from the indoor air is absorbed into the refrigerant, thus cooling the air as it passes over the coil. The indoor unit's blower fan then pumps the chilled air back through the home's ductwork out into the various living areas.

Does using AC use more gas?

Does Your Car's AC Use Gas? In short, yes, but not really enough to matter, according David Bennett, manager of repair systems for the American Automobile Association (AAA). “The AC system, when operating, does add a slight load to the engine, which could slightly increase gas usage,” he says.


2 Answers

The System.Diagnostics.Process class has a property containing the start time which you can use to calculate how long it has been running:

var current = System.Diagnostics.Process.GetCurrentProcess(); DateTime startedAt = current.StartTime 
like image 109
Lee Avatar answered Sep 30 '22 20:09

Lee


Use StopWatch class for this feature.

Even if quite overkill, it will always work, even if the user changes the clock or even if there is some daylight saving changes during the process. - Julien Lebosquain (Comment to my answer.)

like image 21
Nikhil Agrawal Avatar answered Sep 30 '22 18:09

Nikhil Agrawal