Re: need help w/ multi-threaded, multi-CPU tick count / stopwatch

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Feb 14, 1:44 pm, "not_a_commie" <notacom...@xxxxxxxxx> wrote:
So I have a motherboard with multiple CPU sockets. It seems that if I
create a StopWatch on one thread and then call the Elapsed member from
a different thread that sometimes I get a tick count that's a million
miles away.

My thinking is that I can subclass the StopWatch. Then when the
Elapsed member is called, I can invoke it on the thread that the
StopWatch class was created on. True? How?

Or is there an easy way that I could scan through all processors and
read their tick counts? That way I could just have my own timer class
that stores counts for all CPUs.

Can the BeginThreadAffinity help me somehow? I'm totally at a loss as
to what that function does for me.

Is there some other solution?

I'm using .NET 2.0.

Thanks.

Hi,

The StopWatch class isn't inherently thread-safe. Are you
synchronizing access to it appropriately. Can you post some code
demonstrating the problem?

Brian

.



Relevant Pages

  • need help w/ multi-threaded, multi-CPU tick count / stopwatch
    ... So I have a motherboard with multiple CPU sockets. ... My thinking is that I can subclass the StopWatch. ... Elapsed member is called, I can invoke it on the thread that the ... StopWatch class was created on. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: need help w/ multi-threaded, multi-CPU tick count / stopwatch
    ... a different thread that sometimes I get a tick count that's a million ... My thinking is that I can subclass the StopWatch. ... Elapsed member is called, I can invoke it on the thread that the ... StopWatch class was created on. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Need help with the Stopwatch class...please help
    ... If after checking out the above you are still having troubles please post ... I am playing a little bit with the stopwatch class from Daniel Moth ... little stopwatch with the time format...if I use a timer to ...
    (microsoft.public.dotnet.framework.compactframework)