I have a custom attribute class. The custom attribute runs on every request. Since my requests are async. I want to know how many times my method on custom attribute runs.
Is there a way to count the execution of method or create a trace point on Visual Studio 2022?
I tried to look the breakpoint settings. On actions, I put {hitcount} as a message output window. But did not work.
As @stuartd said, if you want to count the execution of method or create a trace point, you can add a counter to your code. For detailed steps, please check the following:
1.Create a static variable outside the method. Increment it every time method gets called.
public static int counter = 0;
public void myMethod()
{
Interlocked.Increment(ref counter);
}
2.Set tracepoints in your method. Enter the message {counter} into the Show a message in the Output Window text box.
Test result
Doc Referred: