CSharpTest.Net
Run() Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > Run Method : Run() Method

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration) 
Public Overloads Function Run() As Integer
C# 
public int Run()

Example

Library/Library.Test/TestScriptRunner.cs

C#Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO From CMD.exe"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    ProcessExitedEventHandler h = delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };
    runner.ProcessExited += h;
    runner.ProcessExited -= h;
    Assert.AreEqual(0, runner.Run());
    Assert.IsFalse(mre.WaitOne(250, false));
}
VB.NETCopy Code
Using runner As New ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO From CMD.exe")
    Dim mre As New ManualResetEvent(False)
    Dim h As ProcessExitedEventHandler = Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function
    runner.ProcessExited += h
    runner.ProcessExited -= h
    Assert.AreEqual(0, runner.Run())
    Assert.IsFalse(mre.WaitOne(250, False))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys