I am currently building a VS code extension to visualize C# variables and datatables. And I have successfully achieved this in single threaded application by calling these in sequence:
- But I am currently facing issues in multi threaded C# application, As it returns multiple threads and I can't figure which thread id I should pass in stack trace request. Here is my code to get threads and other request.
- Can I get active thread id on which breakpoint is paused? or do I have to check for all threads? and How?
This is what i have done for single threaded C# application in javascript.
// Get Active Debug Session
const session = vscode.debug.activeDebugSession;
// Get Thread
const threadResponse = await session.customRequest('threads');
const threadId = threadResponse.threads[0].id;
// Get StackFrame
const stackResponse = await session.customRequest('stackTrace', { threadId: threadId, startFrame: 0 });
const frameId = stackResponse.stackFrames[0].id;
// Get Scope
const scopeResponse = await session.customRequest('scopes', { frameId: frameId });
const variableReference = scopeResponse.scopes[0].variablesReference;
// Get Variable
const variableResponse = await session.customRequest('variables', { variablesReference: variableReference });
const variables = variableResponse.variables;