ITool 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 a string representation of that exception will be packaged in the Message property of the tool's RunStatus. Should this occur, the Result property of the tool's RunStatus will be set to Error. It is the user's responsibility to examine the tool's RunStatus after calling Run.

Namespace: Cognex.Vision
Assembly: Cognex.Vision.Core.Net (in Cognex.Vision.Core.Net.dll) Version: 9.10.0.0
Syntax

void Run()
Remarks

  • Changed Raised when the state of this tool changes.
  • Running Raised at the start of the Run method.
  • Ran Raised at the end of the Run method.

Imports Cognex.Vision
Private Function RunTool() As Boolean
  mTool.Run() ' a previously created and configured tool...
  Dim aRunStatus As Cognex.Vision.IRunStatus = mTool.RunStatus
  If (aRunStatus.Result = ToolResultConstants.Error) Then
    If (Not aRunStatus.Message Is Nothing) Then
      MessageBox.Show(aRunStatus.Message)
    End If
    RunTool = False
  Else
    RunTool = True
  End If
End Function
using Cognex.Vision;
private Boolean RunTool()
{
  mTool.Run(); // a previously created and configured tool
  <see cref="T:Cognex.Vision.IRunStatus">IRunStatus</see> aRunStatus = mTool.RunStatus;
  if (aRunStatus.<see cref="P:Cognex.Vision.IRunStatus.Result">Result</see> == <see cref="T:Cognex.Vision.ToolResultConstants">ToolResultConstants</see>.Error)
  {
    if (aRunStatus.<see cref="P:Cognex.Vision.IRunStatus.Message">Message</see> != null)
    {
      MessageBox.Show(aRunStatus.<see cref="P:Cognex.Vision.IRunStatus.Message">Message</see>);
    }
    return false;
  }
  else
  {
    return true;
  }
}
See Also