Export (0) Print
Expand All

IVsaSite.GetEventSourceInstance Method

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;

Parameters

itemName
The specified item name.
eventSourceName
The specified event source name.

Return Value

Returns the event source to the engine.

Remarks

Binding user code to events in Script for the .NET Framework is a relatively simple process.

  1. 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.
  2. 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.
  3. 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.
  4. 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.

Exception Type Condition
EventSourceInvalid The specified event source does not exist for the given item.
CallbackUnexpected The host was not expecting a call at this time.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

IVsaSite Interface | IVsaSite Members | Microsoft.Vsa Namespace | IVsaCodeItem.AddEventSource | IVsaSite.GetEventSourceInstance | IVsaEngine.Run

Show:
© 2015 Microsoft