I’m trying to write a program that keeps executing a method without having to use a timer. For example, I want to have a program that shows a list of currently running processes. Obviously, it’s constantly changing. I don’t want to use a timer that gets the list of processes every second and adds them to the list, because it doesn’t look very elegant to me. Is there any special way to do that? How can I make a service that would make this happen?
Share
You can spawn a lower priority thread with an infinite (until the process exits) loop to update your process list periodically. Without more information about what kind of control you’re using or whatever I can’t really help you out with Control update delegates, but the rough skeleton of your function would be:
In my case I just capture the processes with windows, and list those windows titles in a listbox (lstProcesses)
Now, to spawn this thread:
Obviously this is a very basic implementation, but hopefully it’ll give you a rough idea on how to do what you want.