Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 36,658 times

Contents

Downloads

Related Categories

Launching a process from Windows Forms - Wrapping Up

mag37

Wrapping Up

Sample Image - LaunchProcess.png

As shown in the picture above, the form is quite simple.  It consists of a rich text box to show the standard output and standard input, a button to run a process (Ok), and a button to cancel the process (Cancel).

The Ok button calls the Start() method on ProcessCaller and the Cancel button calls the Cancel() method.  The events StdOutRecieved and StdErrReceived are handled by the following function:

    private void writeStreamInfo(object sender, DataReceivedEventArgs e)
    {
        this.richTextBox1.AppendText(e.Text + Environment.NewLine);
    }

Improvements

Adding a progress bar to the form is one nice improvement for the user interface.  Of course, you have to know the progress of the program being run.  One option is to have the script tell you explicitly in the standard output with lines such as: "Percent completion = 30".  Your "writeStreamInfo" function would filter those lines and update a progress bar.

Standard Error can be displayed in red or some other color (or in a separate rich text box) to highlight any errors found.  At the end of the process, a dialog could be displayed with a list of all errors.

Providing support for standard input shouldn't be too difficult, but integrating it with the windows form may be tough.  Perhaps a separate single-line text box whose contents are sent to the standard input stream through a method on ProcessCaller.

These are just a few ideas of improvements you can make.

Conclusion

Using the class AsyncOperation reduced the design complexity of this program.  Hopefully, the class ProcessCaller will provide you just as much help in reducing the complexity of running scripts and monitoring the output.

Mike Mayer is a Microsoft MVP in Visual C#.

Comments

  • Posted by laplace on 10 Apr 2004

    Perhaps you can use this software:
    http://www.accusoft.com/imaging/imagegear/ig_formats.asp

    Regards,
    Magnus Strand

  • convert postscript into image(help)

    Posted by vida65 on 22 Mar 2004

    hi
    i want to convert a postscript file to image with visual c# .net.
    who can help me?