In a VS extension project, I am trying to create a mapping of the process threads, cast as both EnvDTE.Thread (to access the Freeze and Thaw methods), and System.Threading.Thread (to access the ManagedThreadId property).
It should ideally be as follow, but the cast will not compile, saying that it cannot cast from System.Threading.Thread to EnvDTE.Thread.
var threads = new Dictionary<EnvDTE.Thread, System.Threading.Thread>();
foreach (System.Threading.Thread thread in this.dte.Debugger.CurrentProgram.Threads) {
threads.Add((EnvDTE.Thread)thread, thread);
}
How can I force the cast, knowing that it will not throw an exception (unless I am missing something here)?
Edit: it does throw an InvalidCastException.