How to start a process as a child of VS? #491
Unanswered
sharpninja
asked this question in
Q&A
Replies: 2 comments
-
https://stackoverflow.com/questions/3342941/kill-child-process-when-parent-process-is-killed#4657392 |
Beta Was this translation helpful? Give feedback.
0 replies
-
I do like this Main Processin your case VS var id = Process.GetCurrentProcess().Id;
var si = new ProcessStartInfo("ChildProcess.exe", id.ToString())
{
UseShellExecute = false,
CreateNoWindow = false,
};
var c = Process.Start(si);
Console.WriteLine($"Child {c?.Id ?? 0}");
Console.WriteLine("Press key to exit");
Console.ReadKey(); Childyour web server using System.Diagnostics;
Console.WriteLine("Child Process, World!");
Console.WriteLine($"Parent process {args[0]}");
await Task.Factory.StartNew(state =>
{
int.TryParse(args[0], out var id);
var p = Process.GetProcessById(id);
p.WaitForExit();
}, args[0]);
Console.WriteLine("Parent process exit"); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm developing an extension that uses an ASP.Net Core webserver in the background. I need it to be terminated when VS closes, even if the VS process is terminated. I know that VS spawns child processes to do background work that function this way. How do I launch my webserver as a child of VS?
Beta Was this translation helpful? Give feedback.
All reactions