Enable breakpoint B if breakpoint A has been hit

前端 未结 2 473
不知归路
不知归路 2021-01-31 18:58

I\'m often find myself setting a breakpoint A somewhere in the code and manually enabling one or more breakpoints when this breakpoint is hit. A typical case is when I\'m debugg

2条回答
  •  孤街浪徒
    2021-01-31 19:20

    This is about the best I think you could do, but it seems too big of a hack to even try, because it involves adding a variable...

    string breakpointToStopOn = string.Empty;
    Console.WriteLine("HERE"); // You can set breakpoint A here, 
                               // with a condition (right click on the breakpoint, then selectCondition),
                               // that sets breakpointToStopOn = "A"
    Console.WriteLine("B"); // and you can set your breakpoint here with this condition
                            // (breakpointToStopOn == "A");  
    

    You won't actually be able to stop on the Console.WriteLine("HERE") line, but you could enable or disable the breakpoint, which would in effect enable the other breakpoint.

    Beware though, conditional breakpoint statements will seriously degrade performance of your app while debugging.

提交回复
热议问题