Uwe Keim
Uwe Keim

Reputation: 40756

Possible to kill/terminate a certain thread in the Visual Studio debugger?

Currently trying to hunt a potential race condition, I paused my WinForms application in the visual studio debugger.

The Threads window shows a lot of thread which one of them I suspect to be the root cause for the blocking.

enter image description here

I would now love to do the following:

  1. Select a thread
  2. Right-click the thread
  3. Select "Kill thread" from the context menu

Unfortunately I found no option that would allow me to do something like that.

My question:

Is it possible to kill/terminate a certain thread in the Visual Studio 2013 debugger?

Upvotes: 8

Views: 7347

Answers (3)

Mark Virchenko
Mark Virchenko

Reputation: 71

You could simply freeze a thread (Why would you need to exactly kill it?)enter image description here

Upvotes: 0

Stefano Bafaro
Stefano Bafaro

Reputation: 913

From Microsoft Technet I found Process Explorer that can solve your problem.

Upvotes: 3

Chetan
Chetan

Reputation: 131

It's not easy to just kill a thread because the designers of the language want to avoid the following problem: your thread takes a lock, and then you kill it before it can release it... now anyone who needs that lock will get stuck.

What you have to do is use some global variable to tell the thread to stop. You have to manually, in your thread code, check that global variable and return if you see it indicates you should stop.

Please note that what you are asking is not possible as it stands.

Upvotes: 0

Related Questions