Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Waiting for the process to exit
#2
Hi, I don't have QM and have never used it, but if you hand the task off to LA, maybe you could use this (untested, no way to test), and apologies if it's a wild goose chase. (I think the required 'using' directives are already global, but I'm not sure.)
 
Code:
Copy      Help
string relaysProgramPath = @"C:\B.exe";
string arguments = "/start \"My arg\"";
Process.Start(relaysProgramPath, arguments);

// Set the upper limit of loop attempts and the interval time (in seconds)
int maxAttempts = 30;
int interval = 1;

// Loop to check the number of processes, maximum 30 attempts
for (int i = 1; i <= maxAttempts; i++) {
    // Get the number of "A.exe" processes
    Process[] processes = Process.GetProcessesByName("A");
    int processCount = processes.Length;
    
    // Check the number of processes
    if (processCount <= 1) {
        // If the number of processes is less than or equal to 1, break the loop
        break;
    }
    
    // Wait for the specified interval time
    Thread.Sleep(interval * 1000);
}

print.it("New A.exe has exited");


Messages In This Thread
Waiting for the process to exit - by Davider - 07-08-2023, 02:32 AM
RE: Waiting for the process to exit - by burque505 - 07-08-2023, 05:31 PM
RE: Waiting for the process to exit - by Davider - 07-08-2023, 10:27 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)