CogInputLine CreateEventSink Method Cognex VisionPro 9.24
Create an object in the event thread of this input line. This allows single-threaded objects to sink input line events efficiently.

Namespace: Cognex.VisionPro
Assembly: Cognex.VisionPro.Core (in Cognex.VisionPro.Core.dll) Version: 91.0.0.0
Syntax

public Object CreateEventSink(
	string progIDOrClassID
)

Parameters

progIDOrClassID
Type: System String

A ProgID or ClassID that identifies the type of object to create.

Return Value

Type: Object

The object that was created.

Remarks

Create an object in the event thread of this input line. This allows single-threaded objects to sink input line events efficiently.

This input line's event thread runs at a high priority, which means that the event handler you implement in the specified class will also run at a high priority. You should take care to limit the amount of processing time required to service events.

This function creates an object within the apartment of the input line's event thread but it does not actually connect the input line events to the object. In Visual Basic events are connected by assigning the input line to a WithEvents variable declared in the class that was created. For example if your event sink class (named MyInspection) contains the following code:

Public WithEvents InputLine As CogInputLineEvents Private Sub InputLine_LowToHigh(ByVal Overlap As Long) Run the inspection now End Sub

You would use the code shown below to create the event sink class and connect it to the input line event source when your program starts:

Dim FGs As New CogFrameGrabbers, DiscreteIO As CogDiscreteIO Set DiscreteIO = FGs(0) Dim InputLine As CogInputLine Set InputLine = DiscreteIO.InputLines(0) Dim Inspection As MyInspection Set Inspection = InputLine.CreateEventSink("MyProject.MyInspection") Set Inspection.InputLine = InputLine

Note: If you wish to use this function to implement true multithreading in a Visual Basic 6 application, the object specified by progIDOrClassID must be defined in an ActiveX DLL project.

See Also