diff options
author | Alan McGovern <alan.mcgovern@gmail.com> | 2012-05-01 00:25:17 +0400 |
---|---|---|
committer | Alan McGovern <alan.mcgovern@gmail.com> | 2012-05-01 00:25:17 +0400 |
commit | 6d323263ced767b05dfad77cec7f2c0d363d5956 (patch) | |
tree | 11d4addd040d3e6e8ca35d56bce86a304ccd43bb | |
parent | e317a729a66719b35382300fb82a9c8591ac4f8a (diff) |
[Ide] Only manually run pending events twice a second
Try to avoid calling Application.RunIteration too frequently,
it is a significant slowdown in some cases.
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs index 2b5fe24d1a..087afec850 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DispatchService.cs @@ -119,6 +119,7 @@ namespace MonoDevelop.Ide throw new Exception (errormsg, mc.Exception); } + static DateTime lastPendingEvents; public static void RunPendingEvents () { // The loop is limited to 1000 iterations as a workaround for an issue that some users @@ -126,10 +127,17 @@ namespace MonoDevelop.Ide // causing the loop to never end. int n = 1000; - Gdk.Threads.Enter();
- while (Gtk.Application.EventsPending () && --n > 0) {
- Gtk.Application.RunIteration (false);
+ Gdk.Threads.Enter(); + + // Check for less than zero in case there's a system time change + var diff = DateTime.UtcNow - lastPendingEvents; + if (diff > TimeSpan.FromMilliseconds (500) || diff < TimeSpan.Zero) { + lastPendingEvents = DateTime.UtcNow; + while (Gtk.Application.EventsPending () && --n > 0) { + Gtk.Application.RunIteration (false); + } } + Gdk.Threads.Leave(); guiDispatcher (); } |