日期:2014-05-17  浏览次数:21026 次

程序运行过程中,如何在中断执行?
例:

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

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

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Func_1();
            Func_2();
            Func_3();
        }

        private void Func_1()
        {
            MessageBox.Show("1");
        }

        private void Func_2()
        {
            MessageBox.Show("2");
            //return;
        }

        private void Func_3()
        {
            MessageBox.Show("3");
        }
    }
}


===================================================
想在执行FUNC_2函数时就中断执行,也就是不执行函数FUNC_3
但是不想通过判断if(FUNC_2())返回状态的方式来实现 请问有其他办法么?(就好比发生了异常 这样button1_Click就执行到FUNC_2就不接着往下执行了)

------解决方案--------------------
那就在Fun2里面抛出异常,button1_Click里面捕获异常呗