Can I ignore the WaitHandle.SignalAndWait call to profile performance?

I just downloaded a trial version of ANTI Performance Profiler from Red Gate and studied some of my commands. Immediately, I notice that there is a specific section of code that ANTS reports that it consumes up to 99% of the processor time.

I am completely unfamiliar with ANTS or performance profiling in general (that is, other than self-profiling, using what I'm sure is extremely rude and frowned on such methods as double timeToComplete = (endTime - startTime).TotalSeconds), so I still play around the application and find out how it is used. But I called the developer responsible for the code in question, and his immediate reaction was “Yes, it doesn’t surprise me that it says, but this code calls SignalAndWait [which I could see myself, thanks to ANTS], which doesn’t use any processor, it just sits there, waiting for something. " He advised me to simply ignore this code and look for everything that I could find.

My question is: is it true that SignalAndWait does not require any processor overhead (and if so, how is this possible?), And is it reasonable for the performance profiler to consider it taking up 99% of the processor time? I find this especially curious, because if it is 99%, this suggests that our application is often idle, right? And yet its performance has recently become rather sluggish.

As I said, I really start when it comes to this tool, and I don't know anything about the WaitHandle class. Therefore, any information that will help me understand what is happening here will be appreciated.

+3
source share
2 answers

A WaitHandle .

- , .

WaitHandle (, ..), WakeUp.

WaitHandle Thread.Sleep , Sleep , , WaitHandle , .

+1

, . EventWaitHandle 2 reset. EventWaitHandle AutoReset, , , , reset , .

, EventWaitHandle ManualReset, , reset , , EventWaitHandle , , reset ,

EventWaitHandle h1, h2;
h1 = new EventWaitHandle(true, EventWaitHandle.ManualReset); // the event is already signaled.
h2 = new EventWaitHandle(false, EventWaitHandle.ManualReset);
while(true)
{
  WaitHandle.SignalAndWait(h2,h1);
}

, - h1.Reset(), SignalAndWait.

, .

, http://msdn.microsoft.com/en-us/library/system.threading.eventwaithandle.aspx

0

Source: https://habr.com/ru/post/1711116/


All Articles