Skip to content

Instantly share code, notes, and snippets.

@kthompson
Created November 11, 2011 17:32
Show Gist options
  • Save kthompson/1358633 to your computer and use it in GitHub Desktop.
Save kthompson/1358633 to your computer and use it in GitHub Desktop.
Short-circuiting Application.DoEvents
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Jeter
{
public class DoEventsHelper
{
private static readonly List<MethodInfo> Actions = new List<MethodInfo>();
public static void ExecuteWithoutNesting(Action action)
{
var method = action.Method;
if (Actions.Contains(method))
return;
Actions.Add(method);
try
{
action();
}
finally
{
Actions.Remove(method);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment