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 58131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:48:00+00:00 2026-05-10T17:48:00+00:00

From C#, is it possible to detect the number of context switches that occurred

  • 0

From C#, is it possible to detect the number of context switches that occurred while executing a block of code on a particular thread? Ideally, I’d like to know how many times and what CPU my thread code was scheduled on.

I know I can use tools like Event Tracing for Windows and the associated viewers, but this seemed a bit complicated to get the data I wanted.

Also, tools like Process Explorer make it too hard to tell how many switches occurred as a result of a specific block of code.

Background: I’m trying to test the actual performance of a low level lock primitive in .NET (as a result of some comments on a recent blog post I made.

  • 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. 2026-05-10T17:48:00+00:00Added an answer on May 10, 2026 at 5:48 pm

    It looks like procexp might be using the kernel thread (KTHREAD) or executive thread (ETHREAD) data structures that have a ContextSwitches field on them. It might be possible to get this from managed code.

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

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Yeah, You're almost there. A delegate refers to a method… May 11, 2026 at 10:11 am
  • added an answer But is it fool proof, or is there still some… May 11, 2026 at 10:11 am
  • added an answer In the current mobile space, largest installed base + limited… May 11, 2026 at 10:11 am

Related Questions

From C#, is it possible to detect the number of context switches that occurred
Is it possible to use a C++ .lib file from within a C# program?
How can I call a C++ function from a C program, is it possible?,
reading excel files from C# working well in 32 bit version server. It is
Using NHibernate from C# and only HQL (not SQL) in a way that is
I have a swf that is run from C:/ in the browser instead of
Is there an API to access Subversion from C#?
I need to call an external dll from c#. This is the header definition:
What is the best way to print stuff from c#/.net? The question is in
Is there a better way to call MSBuild from C#/.NET than shelling out to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.