Is there a way to detect process starts (whena new program is run) without EnumProcesses or any other listing and comparing method. Is there an event based approach?
Related
I have a service in vb.net and i am about to set another File system watcher. So i will have 2 in total.
One fswatcher triggers when there is a change in a certain file.txt, and the other one triggers when there is a change in a directory.
Each trigger goes to a different code method. So they do not collide(they dont share the same methods in the app).
So my question is, Is every fswatcher running in a thread?
So if i get two triggers will the code from fswatcher1 run in another thread than fswatcher2? Or will the one fswatcher wait for the other one to finish 1st?
Yes, though you can set the 'SynchronizingObject' property if you want enable locking mechanism between the two
I've written a hot folder utility which works great when one file at a time is dropped. When a file is dropped into the hot folder, I add the filename to an array and then use a timer event to see if the array is empty and if it isn't, take the 1st value and start processing.
If I drop 2 files the first file is processed before the 2nd file is processed. I've been researching Background workers and struggling to implement. Any insight on how to get each timer event to trigger in a new thread easily?
My program checks if there is a new version of itself. If yes it would exit and start an updater that replaces it and then restarts.
My problem is that I haven't found any info on how to make process start right after closing the actual program.
Any suggestions?
Thanks in advance
I intended to add a comment, but I'm too low in points here. The updater itself should probably contain a check to determine whether your application is running an instance, and it should contain a timeout loop that performs this check and factor the timeout following it's startup state. That way you can awaken it, and close your application. The updater should just determine your application is not running, compare versions perform the intended update operation.
a possible solution would also be to create a task via tash sceduler or cron job, starting an out of process application, like CMD.exe.. which brings me to my original comment-question: in regards to what Operating System(s) and Platform(s) is your program intended for?
I am trying to detect / get notified whenever a new process is created in MAC. The easiest way is to poll all the processes and see if a new process has been launched but that is too time consuming and i wanted to know if i could somehow get some notification whenever a new process is launched using "forked" and "execve". Here is what i have already found :
On how a new process is launched in MAC :
OS X is a variety of Unix. New processes are created with the fork() system call. This creates an almost identical copy of the process that makes the call (the difference is that fork returns 0 in the child and the pid of the child in the parent). It's then normal to use one of the exec() syscalls in the child to transform the child into a process running a different executable.
How is new application launched on Mac?
On getting the list of all processes through polling
http://www.cocoabuilder.com/archive/cocoa/92971-bsd-processes-with-code.html
I have also gone through kAuth kext thing, but it seems beyond my level unless i have some example code for made simple so that i can understand on how to generate the kext and use it in a sample app.
https://developer.apple.com/library/mac/technotes/tn2127/_index.html
NSWorkspace has a notifier but that is only true for applications and not for all processes.
Any tutorial/ sample code with some basic understanding on how to go about this problem, will be greatly appreciated.
Can any one please tell me about the life of a Process Identification (PID) in Windows Server.
Does it remain same for a long process, I mean after a day or two?
I am saving PIDs in my application and want to evaluate the process on the basis of their IDs.
It doesn't change as long as the process is still running.
http://blogs.msdn.com/b/oldnewthing/archive/2011/01/07/10112755.aspx
If you shut down the program, or kill it, and then restart it, you will get a new process id.
If you start the program you can use Process.WaitForExit. If you are starting the programs, I'd start each process in a new thread and use Process.WaitForExit.
msdn.microsoft.com/en-us/library/fb4aw7b8.aspx
For a different process check out the following website: http://alperguc.blogspot.ca/2008/11/c-process-processgetprocessesbyname.html
It shows how to find a process and attach to it's Exited event.