At my consulting company, we use some very expensive simulation software. I need a means to monitor the usage of these applications/processes (in the background, using C#). The idea is that when someone runs a particular application, they are prompted to enter the job name. Then, when they close the program, the amount of time they used it is sent to a database residing on the network. This way we can recoup the costs of the software by charging our clients on a $/min basis. Aside from the prompt, the program must be nearly invisible to users.
I have thought of a few ways of doing this, but I’m not sure what’s best:
-
Have a program that runs on startup, with only a tray icon. I suppose then I would have to have a backgroundworker monitoring the processes continuously, perhaps sleeping the thread, and checking the processes every 5 minutes or so.
-
Use something like Quartz.net, on startup and with a tray icon. If this is even applicable on a minute-by-minute basis. I am not very familiar with Quartz.net, but from my research it looks maybe do-able.
-
Use some kind of Windows Service. This one I am least familiar with.
Which method would be most fruitful? Thanks
You could write a simple C# program that upon execution collects the required information and start time.
Then by using the
Processclass you execute the simulation software.Wait for the process to end using
WaitForExit()and do whatever is needed with the execution time etc.So essentially you end up with an application that simply collects the required information, launches the main application, waits for the application to end and does whatever is needed with the total execution time. As far as being invisible to the user, you could just minimize the main window ( which also acts as the form for collecting the needed info ) while waiting for the application to end.
Here is a small example of starting an executable within C#.