Gets a reference to an event source previously added to a script engine using the IVsaCodeItem.AddEventSource method.
[Visual Basic] Function GetEventSourceInstance( _ ByVal itemName As String, _ ByVal eventSourceName As String _ ) As Object [C#] object GetEventSourceInstance( string itemName, string eventSourceName ); [C++] Object* GetEventSourceInstance( String* itemName, String* eventSourceName ); [JScript] function GetEventSourceInstance( itemName : String, eventSourceName : String ) : Object;
- The specified item name.
- The specified event source name.
Returns the event source to the engine.
Binding user code to events in Script for the .NET Framework is a relatively simple process.
- The host adds event sources to user-implemented event handlers by calling the IVsaCodeItem.AddEventSource method, or by adding an AppGlobal object for languages that do not support implicit event binding, and passing in the name of the event source and its type.
- Using this information, the engine compiles the code to the event-source item and generates any necessary start-up code to enable events at runtime.
- When the host calls the IVsaEngine.Run method, the engine calls back on the IVsaSite.GetEventSourceInstance method and pulls the event sources into the engine.
- Once it has a reference to the event source, the engine can hook up the user code and enable the engine to respond to events raised by the host object.
Because multiple items with identical names may have been added to more than one code item, the name of the item requesting the event source is given as the itemName parameter. The eventSourceName parameter is the same as the eventSourceName parameter originally passed to the engine in the call to the IVsaCodeItem.AddEventSource method.
The itemName and eventSourceName parameters must be valid names previously added by the host.
The following table shows the exceptions that the GetEventSourceInstance method can throw.
|EventSourceInvalid||The specified event source does not exist for the given item.|
|CallbackUnexpected||The host was not expecting a call at this time.|
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family