I want to prevent a button click from queuing. In testing I have a Form, a Button and in the Code-Behind I have the event handler:
    private void button1_Click(object sender, EventArgs e)
    {
        if (_codeRunning)
            return;
        _codeRunning = true;
        //Application.DoEvents();
        //button1.Enabled = false;
        _click ++;
        Debug.WriteLine("Click Number: " + _click);
        Task.Delay(5000).Wait();
        //button1.Enabled = true;
        _codeRunning = false;
    }
When I run debug and click the button twice or three or four times rapidly, Debug Output shows each click about five seconds after the last one. What I would like it to show is a single Click and drop the rest until first Event is complete.
I have also tried to disable the button, as well as temporarily remove the Handler from the Button_click event. It is all the same results.
 
     
     
     
    