Skip to content

Commit

Permalink
Wpf: Ignore exceptions when calling GC.TryStartNoGCRegion
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Sep 11, 2024
1 parent 89fbc96 commit 021d677
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Eto.Wpf/Forms/Controls/TextBoxHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,17 @@ public string Text
// Improve performance when setting text often
// See https://github.com/dotnet/wpf/issues/5887#issuecomment-1604577981
var endNoGCRegion = EnableNoGCRegion
&& GCSettings.LatencyMode != GCLatencyMode.NoGCRegion
&& GC.TryStartNoGCRegion(1000000); // is this magic number reasonable??
&& GCSettings.LatencyMode != GCLatencyMode.NoGCRegion;

try
{
endNoGCRegion &= GC.TryStartNoGCRegion(1000000); // is this magic number reasonable??
}
catch
{
// Ignore any exceptions, they can apparently still happen even though we check the LatencyMode above
endNoGCRegion = false;
}

try
{
Expand Down

0 comments on commit 021d677

Please sign in to comment.