I have this program which enumerates processes and what I'm trying to do is have a timer to refresh the list, the timer works but I have two questions:
1. The listview flickers badly... I tried using double buffer but it didn't help unless I was using it wrong? any help with this please? do you want to see the code?
2. The important thing is: is there a way to only "refresh" or "update" the list IF the process list changes?
Thanks man, actually DOUBLE BUFFER did the trick, I was sending it at the wrong "time" silly mistake, I appreciate it, this + DOUBLE BUFFER completely gets rid of it.
I would still like to know if there actually is a way to only update if a new process has sprung?
would storing the items in the snap shot and then with a timer check if the snapshot items increase work? it seems like a hassle though :/
would storing the items in the snap shot and then with a timer check if the snapshot items increase work? it seems like a hassle though :/
This is pretty much how I did it in an old project. I kept a list of processes in memory and had a thread that constantly updated the list and another thread that updated the listview control, adding new processes or removing old processes.
This is what I'm doing gpotw, I store the value of how many processes are opened and if there is an increase I add it, works great BUT when it comes to checking if there is a decrease it kind of fails.
I'm going to have to check each process name and then delete accordingly.
Ok so I just have a variable that stores the number of processes and then I check to see if the new variable is bigger ( meaning new processes ) then I add the process, but I can't seem to do the oppisite, (when the new variable is smaller) so how would I go about that?
Well you could use a nested loop... If NewCount < OldCount then for each process in the listview, if it doesn't exist in the new list, remove it. This is how I did it and the main reason I used separate threads, so it wouldnt' tie up the GUI thread with the constant looping. You probably shouldn't compare process names as multiple processes could be running with the same name so maybe compare PID instead.
I didn't look much at webJose's link but if it can signal your application when processes are created and destroyed its probably the best solution...
What I'm doing is creating a list then adding the items to the list view and taking a snapshot every second, I run the loop for as many new processes showed up then add the process to the listview.
I was using process name to check the list but then I obviously saw the problem and now I'm using PID, it seems to work pretty well, I do the same thing to remove the items, for now it is working pretty well, I hope I'm not back for more questions, thanks for your help.
EDIT: there is a much easier way.... when you compare lists, if there was ANY change just "refresh" the list view :/ works best.