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

android traceview

android debugging android-traceview

I made an application and I wanted to see if I can improve performance by running a traceview on a certain activity + it's background tasks.

Algorithm to split an array into N groups based on item index (should be something simple)

algorithm arrays

I feel that it should be something very simple and obvious but just stuck on this for the last half an hour and can't move on.