6

I'm writing a .NET service that monitors application pools. based on specific triggers I'm restarting them. However, I do not want to restart them if the trigger occurred before they were recycled for the last time. How can I know the "last recycle time" of an app pool?

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
Dani Fischer
  • 91
  • 2
  • 4

2 Answers2

2

If the LogEventOnRecycle property is set, you should be able to read this information from the event log using the EventLog Class

Romhein
  • 2,126
  • 2
  • 17
  • 17
0

I went down the rabbit hole of looking through the event log and I was able to detect last when an app pool was last recycled but it was very cpu intensive because you have to read logs from the disk. I would highly suggest using

Process.GetCurrentProcess().StartTime