protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solution oldSolution, Solution newSolution, ProjectId projectId = null, DocumentId documentId = null) { if (newSolution == null) { throw new ArgumentNullException(nameof(newSolution)); } if (oldSolution == newSolution) { return(Task.CompletedTask); } if (projectId == null && documentId != null) { projectId = documentId.ProjectId; } var ev = _eventMap.GetEventHandlers <EventHandler <WorkspaceChangeEventArgs> >(WorkspaceChangeEventName); if (ev.HasHandlers) { return(this.ScheduleTask(() => { var args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId); ev.RaiseEvent(handler => handler(this, args)); }, "Workspace.WorkspaceChanged")); } else { return(Task.CompletedTask); } }
protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solution oldSolution, Solution newSolution, ProjectId projectId = null, DocumentId documentId = null) { if (newSolution == null) { throw new ArgumentNullException(nameof(newSolution)); } if (oldSolution == newSolution) { return(Task.CompletedTask); } if (projectId == null && documentId != null) { projectId = documentId.ProjectId; } var ev = _eventMap.GetEventHandlers <EventHandler <WorkspaceChangeEventArgs> >(WorkspaceChangeEventName); if (ev.HasHandlers) { return(this.ScheduleTask(() => { using (Logger.LogBlock(FunctionId.Workspace_Events, (s, p, d, k) => $"{s.Id} - {p} - {d} {kind.ToString()}", newSolution, projectId, documentId, kind, CancellationToken.None)) { var args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId); ev.RaiseEvent(handler => handler(this, args)); } }, "Workspace.WorkspaceChanged")); } else { return(Task.CompletedTask); } }
private void RaiseDiagnosticsUpdated( IDiagnosticUpdateSource source, DiagnosticsUpdatedArgs args ) { _eventListenerTracker.EnsureEventListener(args.Workspace, this); var ev = _eventMap.GetEventHandlers <EventHandler <DiagnosticsUpdatedArgs> >( DiagnosticsUpdatedEventName ); _eventQueue.ScheduleTask( DiagnosticsUpdatedEventName, () => { if (!UpdateDataMap(source, args)) { // there is no change, nothing to raise events for. return; } ev.RaiseEvent(handler => handler(source, args)); }, CancellationToken.None ); }
protected Task RaiseWorkspaceChangedEventAsync(WorkspaceChangeKind kind, Solution oldSolution, Solution newSolution, ProjectId projectId = null, DocumentId documentId = null) { if (newSolution == null) { throw new ArgumentNullException("newSolution"); } if (oldSolution == newSolution) { return(SpecializedTasks.EmptyTask); } if (projectId == null && documentId != null) { projectId = documentId.ProjectId; } var handlers = _eventMap.GetEventHandlers <EventHandler <WorkspaceChangeEventArgs> >(WorkspaceChangeEventName); if (handlers.Length > 0) { return(this.ScheduleTask(() => { var args = new WorkspaceChangeEventArgs(kind, oldSolution, newSolution, projectId, documentId); foreach (var handler in handlers) { handler(this, args); } }, "Workspace.WorkspaceChanged")); } else { return(SpecializedTasks.EmptyTask); } }
internal void RaiseDiagnosticsUpdated(DiagnosticsUpdatedArgs args) { // all diagnostics events are serialized. var ev = _eventMap.GetEventHandlers <EventHandler <DiagnosticsUpdatedArgs> >(DiagnosticsUpdatedEventName); if (ev.HasHandlers) { var asyncToken = Listener.BeginAsyncOperation(nameof(RaiseDiagnosticsUpdated)); _eventQueue.ScheduleTask(() => ev.RaiseEvent(handler => handler(this, args))).CompletesAsyncOperation(asyncToken); } }
private Task RaiseGlobalOperationStartedAsync() { var ev = _eventMap.GetEventHandlers <EventHandler>(GlobalOperationStartedEventName); if (ev.HasHandlers) { return(_eventQueue.ScheduleTask(GlobalOperationStartedEventName, () => ev.RaiseEvent(handler => handler(this, EventArgs.Empty)), CancellationToken.None)); } return(Task.CompletedTask); }
protected virtual Task RaiseGlobalOperationStarted() { var ev = _eventMap.GetEventHandlers <EventHandler>(GlobalOperationStartedEventName); if (ev.HasHandlers) { return(_eventQueue.ScheduleTask(() => { ev.RaiseEvent(handler => handler(this, EventArgs.Empty)); })); } return(SpecializedTasks.EmptyTask); }
protected virtual Task RaiseGlobalOperationStartedAsync() { var ev = _eventMap.GetEventHandlers <EventHandler>(GlobalOperationStartedEventName); if (ev.HasHandlers) { var asyncToken = _listener.BeginAsyncOperation("GlobalOperationStarted"); return(_eventQueue.ScheduleTask(() => { ev.RaiseEvent(handler => handler(this, EventArgs.Empty)); }).CompletesAsyncOperation(asyncToken)); } return(Task.CompletedTask); }
private EventMap.EventHandlerSet <EventHandler <T> > GetEventHandlers <T>(string eventName) where T : EventArgs { // this will register features that want to listen to workspace events // lazily first time workspace event is actually fired this.Services.GetService <IWorkspaceEventListenerService>()?.EnsureListeners(); return(_eventMap.GetEventHandlers <EventHandler <T> >(eventName)); }
protected virtual Task RaiseGlobalOperationStarted() { var handlers = _eventMap.GetEventHandlers <EventHandler>(GlobalOperationStartedEventName); if (handlers.Length > 0) { return(_eventQueue.ScheduleTask(() => { foreach (var handler in handlers) { handler(this, EventArgs.Empty); } })); } return(SpecializedTasks.EmptyTask); }
private Task RaiseEvent(string eventName, ProgressData progressData) { // this method name doesn't have Async since it should work as async void. var ev = _eventMap.GetEventHandlers <EventHandler <ProgressData> >(eventName); if (ev.HasHandlers) { return(_eventQueue.ScheduleTask(() => { ev.RaiseEvent(handler => handler(this, progressData)); })); } return(Task.CompletedTask); }
private Task RaiseEvent(string eventName) { // this method name doesnt have Async since it should work as async void. var ev = _eventMap.GetEventHandlers <EventHandler>(eventName); if (ev.HasHandlers) { return(_eventQueue.ScheduleTask(() => { ev.RaiseEvent(handler => handler(this, EventArgs.Empty)); })); } return(SpecializedTasks.EmptyTask); }
private Task RaiseEvent(string eventName) { // this method name doesnt have Async since it should work as async void. var handlers = _eventMap.GetEventHandlers <EventHandler>(eventName); if (handlers.Length > 0) { return(_eventQueue.ScheduleTask(() => { foreach (var handler in handlers) { handler(this, EventArgs.Empty); } })); } return(SpecializedTasks.EmptyTask); }