How do I call Perl script in C# application?

后端 未结 2 1948
傲寒
傲寒 2020-12-24 09:45

I want to capture output of a Perl program and display output data (string on screen) in a text box on C# Windows Form.

Here is my main C# code:

pu         


        
2条回答
  •  情深已故
    2020-12-24 10:19

    First you have to update the event handler

        void myProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)    
        {        
             if (txtOutput.InvokeRequired)        
             {            
                   UpdateUIDelegate updateDelegate = new UpdateUIDelegate 
    
                     (UpdateUI);this.Invoke(updateDelegate, e.Data);        
              }
              else UpdateUI(e.Data);
    
         }
    

    and add this line in your btnRun_Click

    proc.WaitForExit();
    

提交回复
热议问题