public int DoIdle(IOleComponentManager mgr) { UIThread.MustBeCalledFromUIThread(); Debug.Assert(!this.isDisposed, "tried to do idle work on a disposed TaskReporter"); lock (queueLock) { // process up to MAX items at a time int MAX = 50; // How to pick a value? I tried a couple values with a project with many errors, and this value seems to work well. This value is also happy for unit tests. while (work.Count != 0 && mgr.FContinueIdle() != 0) { int i = 0; while (work.Count != 0 && i < MAX) { Action workItem = work.Dequeue(); workItem(); ++i; } } if (work.Count != 0) { return(1); } else { return(0); } } }
/// <summary> /// Gets a boolean indicating whether a component can continue idle processing. Returns false when idle processing should stop /// </summary> /// <returns></returns> public bool ContinueIdle() { if (_mgr == null) { _mgr = _context.GetService <IOleComponentManager>(typeof(SOleComponentManager)); } return(_mgr == null || 0 != _mgr.FContinueIdle()); }
public static void OnIdle(IOleComponentManager compMgr) { foreach (var window in _windows) { if (compMgr.FContinueIdle() == 0) { break; } window.Value._filter.DoIdle(compMgr); } }
/// <summary> /// Gets a boolean indicating whether a component can continue idle processing. Returns false when idle processing should stop /// </summary> /// <returns></returns> public bool ContinueIdle() { ThreadHelper.ThrowIfNotOnUIThread(); if (_mgr == null) { _mgr = _context.GetService <IOleComponentManager>(typeof(SOleComponentManager)); } return(_mgr == null || 0 != _mgr.FContinueIdle()); }
public void OnIdle(IOleComponentManager compMgr) { foreach (TextLineEventListener listener in _documents.Values) { if (compMgr.FContinueIdle() == 0) { break; } listener.OnIdle(); } }
public static void OnIdle(IOleComponentManager compMgr) { foreach (var window in _windows) { if (compMgr.FContinueIdle() == 0) { break; } #if FALSE window.Value._filter.DoIdle(compMgr); #endif } }
public static IOleComponentManager Create() { IOleComponentManager cm = Substitute.For <IOleComponentManager>(); uint value; cm.FContinueIdle().ReturnsForAnyArgs(VSConstants.S_OK); cm.FOnComponentActivate(0u).ReturnsForAnyArgs(VSConstants.S_OK); cm.FOnComponentExitState(0u, 0, 0u, 0u, null).ReturnsForAnyArgs(VSConstants.S_OK); cm.FPushMessageLoop(0u, 0u, IntPtr.Zero).ReturnsForAnyArgs(VSConstants.S_OK); cm.FRegisterComponent(null, null, out value).ReturnsForAnyArgs(x => { x[2] = 1; return(VSConstants.S_OK); }); return(cm); }
internal virtual int OnIdle(bool periodic, IOleComponentManager mgr) { if (!this.IsActive) return 0; // here's our chance to synchronize combo's and so on, // first we see if the caret has moved. IVsTextView view = this.lastActiveView; if (view == null) return 0; ISource s = this.GetSource(view); if (s == null) return 0; int line = -1, col = -1; var hr = view.GetCaretPos(out line, out col); if (NativeMethods.Failed(hr)) return 0; if (line != this.lastLine || col != this.lastCol || this.lastFileName == null) { this.lastLine = line; this.lastCol = col; this.lastFileName = s.GetFilePath(); CodeWindowManager cwm = this.GetCodeWindowManagerForView(view); if (cwm != null) { this.OnCaretMoved(cwm, view, line, col); } } s.OnIdle(periodic); // do idle processing for currently-focused file bool moreToDo = false; #if CHECK_ALL_DIRTY_FILES_ON_PERIODIC_IDLE if (periodic && mgr.FContinueIdle() != 0) { // while there is spare idle time, pick a dirty file (if there is one) and do idle processing for it for (int i = 0; i < this.sources.Count; ++i) { Source so = this.sources[i] as Source; if (so != null && so.IsDirty) { so.OnIdle(periodic); if (mgr.FContinueIdle() == 0) { moreToDo = true; break; } } } } #endif return moreToDo ? 1 : 0; }