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

Pass GUID As Parameter To Action Using ASP.NET MVC ContribGrid