public int EnumThreads(out IEnumDebugThreads2 ppEnum) { DebugHelper.TraceEnteringMethod(); var threads = DebuggedProcess.GetThreads(); ppEnum = new AD7ThreadEnum(threads); return(VSConstants.S_OK); }
// EnumThreads is called by the debugger when it needs to enumerate the threads in the program. public int EnumThreads(out IEnumDebugThreads2 ppEnum) { if (_mixedMode) { ppEnum = null; return VSConstants.E_NOTIMPL; } AssertMainThread(); AD7Thread[] threadObjects = new AD7Thread[_threads.Count]; int i = 0; foreach (var keyValue in _threads) { var thread = keyValue.Key; var adThread = keyValue.Value; Debug.Assert(adThread != null); threadObjects[i++] = adThread; } ppEnum = new AD7ThreadEnum(threadObjects); return VSConstants.S_OK; }
// EnumThreads is called by the debugger when it needs to enumerate the threads in the program. public int EnumThreads(out IEnumDebugThreads2 ppEnum) { DebugWriteCommand("EnumThreads"); AssertMainThread(); var threadObjects = new AD7Thread[_threads.Count]; int i = 0; foreach (var keyValue in _threads) { var adThread = keyValue.Value; Debug.Assert(adThread != null); threadObjects[i++] = adThread; } ppEnum = new AD7ThreadEnum(threadObjects); return VSConstants.S_OK; }
public int EnumThreads(out IEnumDebugThreads2 ppEnum) { var xEnum = new AD7ThreadEnum(new IDebugThread2[] { mThread }); ppEnum = xEnum; return VSConstants.S_OK; }
/// <summary> /// Retrieves a list of the threads that are running in the program. (http://msdn.microsoft.com/en-us/library/bb145110.aspx) /// </summary> /// <param name="ppEnum"> Returns an IEnumDebugThreads2 object that contains a list of the threads. </param> /// <returns> If successful, returns S_OK; otherwise, returns an error code. </returns> public int EnumThreads(out IEnumDebugThreads2 ppEnum) { AD7Thread[] listThreads = null; int currentThread = 0; if (m_state != DE_STATE.RUN_MODE) currentThread = GetListOfThreads(out listThreads); // the following code seems to be weird but I had to update each field of this.m_process._threads because, when using // "this.m_process._threads = listThreads;" without having a new thread, VS starts to duplicate the existing threads // and, as a consequence, the call stack entries too. if ((currentThread == -1) || (listThreads == null)) { ppEnum = null; if (currentThread == 0) return VSConstants.S_OK; else return VSConstants.S_FALSE; } if (listThreads.Length != this.m_threads.Length) { foreach (AD7Thread t in this.m_threads) { AD7ThreadDestroyEvent.Send(this, 0, t); } this.m_threads = null; this.m_threads = new AD7Thread[listThreads.Length]; this.m_threads = listThreads; this._currentThreadIndex = currentThread; foreach (AD7Thread t in this.m_threads) { m_engineCallback.OnThreadStart(t); } ppEnum = new AD7ThreadEnum(this.m_threads); } else { if (this._currentThreadIndex != currentThread) { this._currentThreadIndex = currentThread; } for (int i = 0; i < listThreads.Length; i++) { if (this.m_threads[i]._engine != listThreads[i]._engine) { this.m_threads[i]._engine = listThreads[i]._engine; } if (this.m_threads[i]._threadDisplayName != listThreads[i]._threadDisplayName) { this.m_threads[i]._threadDisplayName = listThreads[i]._threadDisplayName; } if (this.m_threads[i]._id != listThreads[i]._id) { this.m_threads[i]._id = listThreads[i]._id; } if (this.m_threads[i]._state != listThreads[i]._state) { this.m_threads[i]._state = listThreads[i]._state; } if (this.m_threads[i]._targetID != listThreads[i]._targetID) { this.m_threads[i]._targetID = listThreads[i]._targetID; } if (this.m_threads[i]._priority != listThreads[i]._priority) { this.m_threads[i]._priority = listThreads[i]._priority; } if (this.m_threads[i]._line != listThreads[i]._line) { this.m_threads[i]._line = listThreads[i]._line; } if (this.m_threads[i]._filename != listThreads[i]._filename) { if (listThreads[i]._filename == "") this.m_threads[i]._filename = ""; else this.m_threads[i]._filename = listThreads[i]._filename; } this.m_threads[i].__stackFrames = listThreads[i].__stackFrames; this.m_threads[i]._suspendCount = listThreads[i]._suspendCount; } ppEnum = new AD7ThreadEnum(this.m_threads); } return VSConstants.S_OK; }
int IDebugProgram2.EnumThreads(out IEnumDebugThreads2 ppEnum) { ThrowIfDisposed(); ppEnum = new AD7ThreadEnum(new[] { MainThread }); return VSConstants.S_OK; }
// EnumThreads is called by the debugger when it needs to enumerate the threads in the program. public int EnumThreads(out IEnumDebugThreads2 ppEnum) { var threadObjects = new AD7Thread[1]; AD7Thread adThread = _threads.Item2; Debug.Assert(adThread != null); threadObjects[0] = adThread; ppEnum = new AD7ThreadEnum(threadObjects); return VSConstants.S_OK; }
// EnumThreads is called by the debugger when it needs to enumerate the threads in the program. public int EnumThreads(out IEnumDebugThreads2 ppEnum) { //Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); ppEnum = new AD7ThreadEnum(m_debuggedProcess.GetThreads().Select(t => { Debug.Assert(t.Client != null); return t.Client; })); return Constants.S_OK; }