public MethodTrack(IServiceProvider sp) { _serviceProvider = sp; _dataService = sp.GetService(typeof(SSrcMLDataService)) as ISrcMLDataService; _srcmlService = sp.GetService(typeof(SSrcMLGlobalService)) as ISrcMLGlobalService; _cursorMonitor = sp.GetService(typeof(SCursorMonitorService)) as ICursorMonitorService; _currentMethod = new Method(); _navigatedMethods = new List <Method>(); _currentCursor = new CursorPos("", 0, 0); if (null != _cursorMonitor) { _cursorMonitor.PropertyChanged += OnCursorMoving; } if (null != _srcmlService) { _srcmlService.SourceFileChanged += OnFileChanged; } }
internal static bool WaitForServiceToFinish(ISrcMLDataService service, int millisecondsTimeout) { AutoResetEvent monitoringStartedResetEvent = new AutoResetEvent(false), updateStartedResetEvent = new AutoResetEvent(false), updateCompletedResetEvent = new AutoResetEvent(false); EventHandler monitoringStartedEventHandler = GetEventHandler(monitoringStartedResetEvent), updateStartedEventHandler = GetEventHandler(updateStartedResetEvent), updateCompleteEventHandler = GetEventHandler(updateCompletedResetEvent); service.MonitoringStarted += monitoringStartedEventHandler; service.UpdateStarted += updateStartedEventHandler; service.UpdateCompleted += updateCompleteEventHandler; Assert.IsTrue(updateStartedResetEvent.WaitOne(millisecondsTimeout)); Assert.IsTrue(monitoringStartedResetEvent.WaitOne(millisecondsTimeout)); Assert.IsTrue(updateCompletedResetEvent.WaitOne(millisecondsTimeout)); service.MonitoringStarted -= monitoringStartedEventHandler; service.UpdateStarted -= updateStartedEventHandler; service.UpdateCompleted -= updateCompleteEventHandler; return(!service.IsUpdating); }
internal static bool WaitForServiceToFinish(ISrcMLDataService service, int millisecondsTimeout) { AutoResetEvent monitoringStartedResetEvent = new AutoResetEvent(false), updateStartedResetEvent = new AutoResetEvent(false), updateCompletedResetEvent = new AutoResetEvent(false); EventHandler monitoringStartedEventHandler = GetEventHandler(monitoringStartedResetEvent), updateStartedEventHandler = GetEventHandler(updateStartedResetEvent), updateCompleteEventHandler = GetEventHandler(updateCompletedResetEvent); service.MonitoringStarted += monitoringStartedEventHandler; service.UpdateStarted += updateStartedEventHandler; service.UpdateCompleted += updateCompleteEventHandler; Assert.IsTrue(updateStartedResetEvent.WaitOne(millisecondsTimeout)); Assert.IsTrue(monitoringStartedResetEvent.WaitOne(millisecondsTimeout)); Assert.IsTrue(updateCompletedResetEvent.WaitOne(millisecondsTimeout)); service.MonitoringStarted -= monitoringStartedEventHandler; service.UpdateStarted -= updateStartedEventHandler; service.UpdateCompleted -= updateCompleteEventHandler; return !service.IsUpdating; }
public MethodTrack(IServiceProvider sp) { _serviceProvider = sp; _dataService = sp.GetService(typeof(SSrcMLDataService)) as ISrcMLDataService; _srcmlService = sp.GetService(typeof(SSrcMLGlobalService)) as ISrcMLGlobalService; _cursorMonitor = sp.GetService(typeof(SCursorMonitorService)) as ICursorMonitorService; _currentMethod = new Method(); _navigatedMethods = new List<Method>(); _currentCursor = new CursorPos("", 0, 0); if (null != _cursorMonitor) _cursorMonitor.PropertyChanged += OnCursorMoving; if(null != _srcmlService) _srcmlService.SourceFileChanged += OnFileChanged; }