How do I run multiple events in a specific order?

I am new to c# and has a question about events on a WPF application. I have two events (Button_Click and myslider_ValueChanged) and would like the myslider_ValueChanged to run after Button_Click. I have tried using EventHandler but it both events still run at the same time. Is there an easier way to do this such as a nested event? Any help is appreciated, thanks. I have attached my EventHandler attempt below.

    namespace program
    {
        public partial class MainWindow : Window
        {

            public event EventHandler _Click;
            public event EventHandler _ValueChanged;

            protected void On_Click(EventArgs e)
            {
                if (_Click != null)
                {
                    _Click(this, e);
                }
            }

            protected void On_ValueChanged(EventArgs e)
            {
                On_Click(EventArgs.Empty);

            }

            private void Initialize()
            {
                _Click += new EventHandler(_Click);
                _ValueChanged += new EventHandler(_ValueChanged);
                _Click += _ValueChanged;
            }


            private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
            {
              //Code here
            }

            private void myslider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
            {
            //Code here
            }

Answers


You should have myslider_ValueChanged call a different method to perform the work, then call that new method from button_click.

For example:

       private void myslider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
           HandleValueSliderChanged();
        }
        private void HandleValueSliderChanged() {
          //Code here
        }

        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
          //Code here
           HandleValueSliderChanged();
        }

Need Your Help

I cannot insert records into Database using HTML Form and PHP

php html mysql apache easyphp

No records show up in my MyPHP Database when I run these scripts.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.