Posted by David Srbecky Sat 20th Jan 2007 16:18 - Syntax is C# - 20 views
Download | New Post | Modify | Hide line numbers
  1.         static void BeginInvokePendingCommands(Control control)
  2.         {
  3.             // Force control to create handle
  4.             if (control.Handle == IntPtr.Zero) {
  5.                 throw System.Exception("No handle");
  6.             }
  7.             control.BeginInvoke((MethodInvoker)delegate {
  8.                 if (pendingCommands.Count > 0) {
  9.                     // Remove one command from list
  10.                     MethodInvoker command = pendingCommands.First.Value;
  11.                     pendingCommands.RemoveFirst();
  12.                     // Perform the command
  13.                     command();
  14.                     // Invoke the rest of the commands
  15.                     BeginInvokePendingCommands(control);
  16.                 } else {
  17.                     Console.WriteLine("No commands to perform");
  18.                 }
  19.                 Application.DoEvents();
  20.             });
  21.         }

PermaLink to this entry https://pastebin.co.uk/9368
Posted by David Srbecky Sat 20th Jan 2007 16:18 - Syntax is C# - 20 views
Download | New Post | Modify | Hide line numbers