For a workflow, you can programmatically read Process → Elapsed Time from the corresponding performance. counter (1) or directly from the System.Diagnostics.Process namespace; for AppDomain, you can set the application level variable at startup to serve as a baseline and measure it manually.
Scott Mitchell actually has a couple of good posts that are still relevant 8 years later, believe it or not (2). Running on Cassini (Vista, VS 2008), I see the exact system uptime:
TimeSpan.FromMilliseconds(Environment.TickCount)
... and the exact execution time of the Process / AppDomain:
foreach (Process p in Process.GetProcessesByName("WebDev.WebServer")) { Response.Write(DateTime.Now.Subtract(p.StartTime).ToString() + "<br/>"); } Response.Write(DateTime.Now.Subtract((DateTime)Application["StartTime"]).ToString());
I can also get the correct PerfomanceCounter , but it can't seem to read the correct value (always zero, under my setup):
Response.Write(new PerformanceCounter("Process", "Elapsed Time", "WebDev.WebServer").NextValue() + "<br/>");
The articles in Scott certainly deserve to be read - they contain information about ProcessInfo and ProcessModelInfo (for example, ProcessModelInfo.GetHistory ), but unfortunately it is not available on Cassini:
Process metrics are only available when the ASP.NET process model is enabled. When working in IIS 6 or later, the isolation mode in this workflow is not supported.
UPDATE: a great explanation of how to count the counter correctly to avoid zero on NextValue () : http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspx p>
NTN
(1) https://serverfault.com/questions/90927/lifetime-of-iis-worker-process-or-appdomai
(2) http://www.4guysfromrolla.com/articles/041002-1.aspx