Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can skip pending clicks by clearing the windows message queue with Application.DoEvents();</p> <p>We use the following custom Event class to solve your problem (preventing multiple clicks and showing a wait cursor if necessary):</p> <pre><code>using System; using System.Windows.Forms; public sealed class Event { bool forwarding; public event EventHandler Action; void Forward (object o, EventArgs a) { if ((Action != null) &amp;&amp; (!forwarding)) { forwarding = true; Cursor cursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; Action(o, a); } finally { Cursor.Current = cursor; Application.DoEvents(); forwarding = false; } } } public EventHandler Handler { get { return new EventHandler(Forward); } } } </code></pre> <p>You can verify that it works with the following example (Console outputs click only if HandleClick has terminated):</p> <pre><code>using System; using System.Threading; using System.Windows.Forms; class Program { static void HandleClick (object o, EventArgs a) { Console.WriteLine("Click"); Thread.Sleep(1000); } static void Main () { Form f = new Form(); Button b = new Button(); //b.Click += new EventHandler(HandleClick); Event e = new Event(); e.Action += new EventHandler(HandleClick); b.Click += e.Handler; f.Controls.Add(b); Application.Run(f); } } </code></pre> <p>To reproduce your problem change the above code as follows (Console outputs all clicks, with a delay):</p> <pre><code> b.Click += new EventHandler(HandleClick); //Event e = new Event(); //e.Action += new EventHandler(HandleClick); //b.Click += e.Handler; </code></pre> <p>The Event class can be used for every control exposing EventHandler events (Button, MenuItem, ListView, ...).</p> <p>Regards, tamberg</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload