If there are multipple running applications, I need to get the most recently used. I know that I can find all running instances of my app using Process, but how to find from this list most recently used instance?
Asked
Active
Viewed 211 times
2 Answers
0
Use Process.StartTime Property of Process class to know which instance started most recently.

Deepak Bhatia
- 1,090
- 1
- 8
- 13
-
using StartTime I can find opened most recently, but how can I find used most recently? For example I started instance A, than started instance B, and than continue working on instance A. In this case instance A is most recently used, and instance B is most recently started. And I need to get instance A – Mirzodaler Ataev Aug 05 '15 at 05:47
-
In that case you can use Application.Activated Event (https://msdn.microsoft.com/en-us/library/system.windows.application.activated(v=vs.110).aspx) in your app and write some information (like process Id and time-stamp) at a common place. Then read that information in you watcher app to know which process was active recently. – Deepak Bhatia Aug 05 '15 at 15:18
0
I found other solution using Z-Order window How to get the z-order in windows?

Community
- 1
- 1

Mirzodaler Ataev
- 81
- 3