Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how you can terminate a process that executed infinitly without using thread
Posted

C#
foreach (Process process in System.Diagnostics.Process.GetProcessesByName("myapp"))
{
    try
    {
        p.Kill();
        p.WaitForExit();
    }
    catch (Win32Exception w32ex)
    {
        // process can't be terminated
    }
    catch (InvalidOperationException ioex)
    {
        // process already exited
    }
    catch (Exception ex)
    {
        // catch-all for any other exception that might occur
    }
}
 
Share this answer
 
it dosen't work :( . I want to develop an application that generate a tone infinitly played and I have to stop it when I clichek on one button without using thread
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900