Run To Click Debugging In Visual Studio 2017

Run To Click

It executes a program until it reaches the target of the Run to Click place. Developers have no need to set temporary breakpoints or perform several steps to execute the code. It will help to stop the line (execution) you want.

Note

Run to Click behavior likes the combination of run time put the break point + F5.

Run execution button : See the Play (Green) button below 

Visual Studio

Let see a simple example: How to use this feature in some of the synchro in our project.

I have created a simple MyMath class, a class handling the Add , Sub , Div. functionality.

  1. public static class MyMath {  
  2.     public static int Add(int value1, int value2) {  
  3.         Console.WriteLine("Add method has called");  
  4.         return value1 + value2;  
  5.     }  
  6.     public static int Sub(int value1, int value2) {  
  7.         Console.WriteLine("Sub method has called");  
  8.         return value1 - value2;  
  9.     }  
  10.     public static int Div(int value1, int value2) {  
  11.         return value1 / value2;  
  12.     }  
  13. }  
And main program.cs file
  1. class Program {  
  2.     static void Main(string[] args) {  
  3.         MyMath.Add(2, 3);  
  4.         MyMath.Add(2, 3);  
  5.         MyMath.Add(2, 3);  
  6.         MyMath.Sub(4, 2);  
  7.         MyMath.Div(2, 0);  
  8.         MyMath.Add(4, 2);  
  9.         MyMath.Sub(4, 2);  
  10.     }  
  11. }  
Run to Execution Break point to Run to Execution

Put the break point in the line No : 13 (MyMath.Add(2, 3) function) and start the application in debug mode.

Code execution will stop in the break point and move the cursor near the MyMath.Div. Click Run execution, click the play button , application starts to execute and will stop at the MyMath.Div function and it shows the execution time

The below diagram describes the steps

Visual Studio

Run to Execution will stop between break point

Execute Run to Click (Old way press F5) options between two break points
the first break point is in the line No : 13 (MyMath.Add(2, 3) function) ,and put one more point in the MyMath. Sub function .Run the application in Debug mode.

Once first break point hits, move the cursor near the MyMath.Div click Run execution , it will start to execute and stop the execution (in between breakpoint ) MyMath.Sub function before reaching MyMath.Div function.

Visual Studio

Run to Execution will stop the between Exception

While running the Run to Execution it will stop in between any exception : Execute the same steps in breakpoint to the Run to Execution section , before calling  one more MyMath.Div function in between and pass the zero value as MyMath.Div(0, 2);

Visual Studio

Application has started executing, it throws an execution & stops.

Note

Exception Unhandled : This is the new resigned dialog in VS 2017 which gives more information about the execution.

I hope you understood the Run To Click feature.


Similar Articles