Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6112533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:45:21+00:00 2026-05-23T14:45:21+00:00

In a VS extension project, I am trying to create a mapping of the

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:45:21+00:00Added an answer on May 23, 2026 at 2:45 pm

    The compilation error you’re getting is a bit of a red herring.

    Debugger.CurrentProgram.Threads already returns a collection of EnvDTE.Thread objects, so your foreach will fail when attempting to cast them to System.Threading.Thread since there is no relation between those classes beyond the name.

    EnvDTE.Thread has an ID property. Would that do what you want without needing to convert to a System.Threading.Thread?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am trying to create an extension in Chrome (a prototype for a
I'm trying to create an Editor Classifier Template project and run it. When I
I'm trying to add an extension method to my MVC 2 project without success
I'm trying to create my own library in a Symfony2 project but I'm having
I am trying to create a extension from an existing view where I have
I'm trying to create an Eclipse plugin to support a proprietary project file format.
I'm trying to create an extension for VS2010. I've only just started and one
For a new project I'm trying to create my business classes first and create
I am trying to create a VISX extension for Visual Studio 2010 that contains
How to hide aspx extension in asp.net project? Ex - http://mcs.com/Profile.aspx http://mcs.com/Profile or http://mcs.com/

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.