CogToolBase Run Method Cognex VisionPro 9.20
Runs the tool. This method is guaranteed to not throw an exception. Any exception generated in the course of running the tool will be caught and packaged in the tool's RunStatus.Exception. Should this occur, the tool's RunStatus.Result will be set to Error and its RunStatus.Message will reference the message that accompanied the exception. It is the user's responsibility to examine the tool's RunStatus after calling Run.

Namespace: Cognex.VisionPro.Implementation
Assembly: Cognex.VisionPro (in Cognex.VisionPro.dll) Version: 80.0.0.0 (80.0.0.0)
Syntax

public virtual void Run()

Implements

ICogTool Run 
Examples

Imports Cognex.VisionPro

Private Function RunTool() As Boolean
  mTool.Run() ' a previously created and configured tool ...

  Dim aRunStatus As Cognex.VisionPro.ICogRunStatus = mTool.RunStatus

  If (aRunStatus.Result = CogToolResultConstants.Error) Then
    If (Not aRunStatus.Exception Is Nothing) Then
      MessageBox.Show("Exception: " + _
        aRunStatus.Exception.ToString())
    End If

    If (Not aRunStatus.Message Is Nothing) Then
      MessageBox.Show("Message: " + _
        aRunStatus.Message)
    End If

    RunTool = False
  Else
    RunTool = True
  End If

End Function
using Cognex.VisionPro;

private Boolean RunTool()
  {
  mTool.Run(); // a previously created and configured tool

  ICogRunStatus aRunStatus = mTool.RunStatus;

  if (aRunStatus.Result == CogToolResultConstants.Error)
    {
    if (aRunStatus.Exception != null)
      MessageBox.Show("Exception: " +
        aRunStatus.Exception.ToString());

    if (aRunStatus.Message != null)
      MessageBox.Show("Message: " +
        aRunStatus.Message);

    return false;
    }
  else 
    return true;
  }
See Also