当事件发生在n> 1的时间时,如何使用"运行到光标"或在VS2005中调试

Syn*_*ter 0 debugging visual-studio

考虑我有一个窗口应用程序,在Visual Studio 2005中开发,有一个按钮.

当按钮被点击第三次(或第n次)而不是第一次时,我需要使用"运行到光标"/调试.我怎样才能做到这一点.?

考虑这是一个示例代码.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace breakPoint
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 10; i++)
            {
                textBox1.Text += "hi ";
                textBox2.Text += "hello ";
                textBox3.Text += "bye ";
            }

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我第n次单击按钮时,我需要在"textBox1.Text"行插入断点.

Jar*_*Par 7

您不能使用Run to Cursor,但可以使用断点.

  1. 在有问题的线上放置一个断点
  2. 右键单击断点红色圆圈
  3. 选择命中计数
  4. 更改组合框ot"当命中数等于"时中断
  5. 将数字1更改为您的值N.
  6. 点击OK

断点现在只会在第N次击中时停止.

编辑

回应澄清.然后将断点放在实际的函数声明本身上.每次点击只会执行一次.然后,您可以进入循环并点击所需的位置.