Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello friends,

I wrote a code in which i am continuously looping through a set of functions let us say around 2-3 functions. Its a while loop, which executes continuously.

Now to check the execution of a particular function i applied break point at that function. I noticed that the debugger breaks on that function, but never executes it.

I also applied a few break points inside the function on which i applied the break point. But the debugger never broke at them. Which means that the compiler never went inside that function.

I will replicate the scenario :

C#
class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {
                fun1();
                fun2();
                fun3();

            }


        }

        static void fun1()
        {
            Console.WriteLine("hello1");
        }

        static void fun2()
        {
            Console.WriteLine("hello2");

        }

        static void fun3()
        {
            Console.WriteLine("hello3");

        }


    }





any suggestions? i mean to say that, what can be the possible reason behind it? I also wrote a thread.sleep(200); instruction. But that dint work too.

If i restart my application( without making any changes i.e i dont remove the break point), it works fine.

Thanks a ton,
Rahul
Posted
Updated 18-Apr-14 7:27am
v5
Comments
Richard MacCutchan 18-Apr-14 9:50am    
What do you mean by "never executes it"? What happens when you step into that method?
S Houghtelin 18-Apr-14 10:11am    
As Richard states, what happens when you step in to the function. How do you know it isn't executing? Try placing your break in the function. Do you have a try catch in the function that is ignoring an error and it is simply returning? Do you have a return value coming back?
Rahul VB 18-Apr-14 11:03am    
Sir, i updated my question. I apologize for posting an incomplete question. I also applied break points within that function, but that function never executes.
ZurdoDev 18-Apr-14 10:30am    
Put a breakpoint inside the function. If it is hitting it, then it is executing it.
Rahul VB 18-Apr-14 10:57am    
I am sorry, i dint post the complete question.

1 solution

Thank you for clarification. At this time, your sample code is correct; and all parts of it should be reachable with the debugger.

I know that in some cases the debugger can make glitches. I never had a problem with cleaning the solution, but some developers reported that "Clean Solution" did not really clean it in some cases. In wost case, you can close Visual Studio and remove all files except real source code. Practically, you just remove the "obj" sub-directory created by the build. Also, all those *.ncb, *.user and *.suo files are not part of the source code, can be deleted. Then the breakpoints will be removed, too, you can add them later. Source files are those presented in the Solution Explorer tree view of Visual Studio, nothing else.

—SA
 
Share this answer
 
Comments
Rahul VB 19-Apr-14 22:57pm    
My thanks sir, great stuff. Sometimes i feel that when you run many functions in a while(true), as it is every instruction is executed in may be micro seconds. So can it be possible for the debugger to not run into that instruction?

By the way very nice, thanks.
- Rahul
Sergey Alexandrovich Kryukov 19-Apr-14 23:36pm    
No, this is impossible; this is not how debugger works with breakpoints. Failures to debug properly a probably related so some bugs, like inconsistent debug information.

You are very welcome.
Good luck, call again.

—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900