I have a parent program that calls a worker console app when and update is found to update the files, this application gets the process ID from the parent via arguments and then calls WaitForExit(). What I wish to know is what would be the best way of then restarting that process, would simply calling Proc.Start() be the best way of doing this? Ex:
static void Main(string[] args)
{
if (args.Length == 2)
{
int ParentID = Convert.ToInt16(args[1]);
Process ParentProc = Process.GetProcessById(ParentID);
ParentProc.WaitForExit();
Console.WriteLine(UpdateHandler.GetUpdates(
Path.GetDirectoryName(ParentProc.MainModule.FileName), args[0]));
ParentProc.Start();
}
else
Console.WriteLine("Error: Invalid number of arguments.");
}
Or should I create a new process to launch it (I would assume using ParentProc.MainModule.FileName)
I would also like to know if there is a managed way to get the parent process not via arguments?
Thanks :)