EventSource.AddSolitaryHandler<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds a single event handler for an event to an EventSource.
protected static void AddSolitaryHandler<T> (T primaryEventSource, ref System.Collections.Generic.List<T> secondaryEventSources, Delegate handler, string key = "") where T : Microsoft.VisualStudio.Shell.Events.EventSource, new();
static member AddSolitaryHandler : 'T * List * Delegate * string -> unit (requires 'T :> Microsoft.VisualStudio.Shell.Events.EventSource and 'T : (new : unit -> 'T))
Protected Shared Sub AddSolitaryHandler(Of T As {EventSourceNew}) (primaryEventSource As T, ByRef secondaryEventSources As List(Of T), handler As Delegate, Optional key As String = "")
Type Parameters
- T
The EventSource-derived type exposing managed events for shell COM events
Parameters
- primaryEventSource
- T
The primary instance of T
- secondaryEventSources
- List<T>
The collection of secondary instances of T
- handler
- Delegate
The event handler to add
- key
- String
The key identifying the event to be handled
Remarks
Some events (e.g. IVsSolutionEvents.OnAfterOpenProject) are handled in a special way by the shell. In order to remain responsive during ASL, sinks handling OnAfterOpenProject are called in batches, taking no more than a small amount of time per batch. If any sinks remain to be called when the batch's timeslice is up, a task will be created to handle the next batch and so on.
EventSource objects are single event sinks as far as the shell is concerned, but ordinary .NET events can have multiple handlers. These handlers cannot be timesliced by the shell in the way normal shell event sinks (e.g. IVsSolutionEvents) can. To allow EventSource objects to participate in advanced repsonsiveness optimizations such as those implemented for IVsSolutionEvents.OnAfterOpenProject, Add/RemoveSolitaryHandler arrange for an EventSource event to have at most a single managed handler. If we get additional managed handlers for the event, we'll create secondary instances of T
for those managed handlers, and those instances will handle *only* the solitary event(s).