Created
November 11, 2011 17:32
-
-
Save kthompson/1358633 to your computer and use it in GitHub Desktop.
Short-circuiting Application.DoEvents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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