From a Windows application developed in .Net framework 4.8, clicking on a button is trying to launch another Windows application that is in a different project (to maintain legacy behavior).
After running the legacy application I am showing the process id in a log textbox and then closing the current application.
var appProcess = new ProcessStartInfo
{
FileName = "LegacyApp.exe",
UseShellExecute = false
};
var legacyProcess = Process.Start(appProcess);
ShowOutput($"Process: {legacyProcess.Id}");
Process.GetCurrentProcess().Kill();
The process starts correctly, I can see the process id both in my output and in the list of processes in the Windows task manager. But after a few seconds, approximately 2-3, the process goes into the “Suspended” state and then closes.
Any idea why this is happening?
Am I using the correct way to launch the new application and close the current one?