Donate

How To Terminate Process That Encounters An Error In C#.NET

Simply set the error data received and terminate the process.
private void button2_Click(object sender, EventArgs e)  
      {  
        foreach (Process p in Process.GetProcesses())  
        {  
          p.ErrorDataReceived += new DataReceivedEventHandler  
            (p_ErrorDataReceived);  
        }  
      }  

      void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)  
      {  
        Process p = (Process)sender;  
        p.Kill();  
     } 

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.