Browse Source

Increase DispatcherPriority of some BeginInvoke calls to ensure that no user input is processed before the callback runs.

This prevents the code editor from 'stealing' the focus when opening a dialog (e.g. Go To) while loading a solution.
addin-manager-package-subdirectories
Daniel Grunwald 12 years ago
parent
commit
1b2ad62f09
  1. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/AbstractInlineRefactorDialog.cs
  2. 40
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Helpers/VisualHelper.cs
  3. 39
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/Helpers/VisualHelper.cs
  4. 2
      src/Main/Base/Project/Src/Project/Behaviors/DefaultProjectBehavior.cs
  5. 2
      src/Main/SharpDevelop/Workbench/AvalonPadContent.cs
  6. 2
      src/Main/SharpDevelop/Workbench/AvalonWorkbenchWindow.cs

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/AbstractInlineRefactorDialog.cs

@ -88,7 +88,7 @@ namespace CSharpBinding.Refactoring @@ -88,7 +88,7 @@ namespace CSharpBinding.Refactoring
protected virtual void FocusFirstElement()
{
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(delegate { this.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); }));
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(delegate { this.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); }));
}
protected void AppendNewLine(Script script, AstNode afterNode, NewLineNode newLineNode)

40
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Helpers/VisualHelper.cs

@ -492,45 +492,5 @@ namespace ICSharpCode.Data.Core.UI @@ -492,45 +492,5 @@ namespace ICSharpCode.Data.Core.UI
else
return GetVisualParentObject(parent, walkThroughPopupRoot, comparePredicate);
}
/// <summary>
/// Runs an Action in the current dispatcher.
/// </summary>
/// <param name="actionToRun"></param>
public static void RunInDispatcher(Action actionToRun)
{
if (Application.Current != null)
RunInDispatcher(Application.Current.Dispatcher, actionToRun);
}
/// <summary>
/// Runs an Action in a given dispatcher.
/// </summary>
/// <param name="dispatcher"></param>
/// <param name="actionToRun"></param>
public static void RunInDispatcher(Dispatcher dispatcher, Action actionToRun)
{
dispatcher.Invoke(DispatcherPriority.Background, actionToRun);
}
/// <summary>
/// Runs through all items in the dispatcher.
/// </summary>
public static void DoEvents()
{
if (Application.Current != null)
DoEvents(Application.Current.Dispatcher);
}
/// <summary>
/// Gives DispatcherFrames of the given Dispatcher priority, if
/// their DispatcherPriority is higher than "DispatcherPriority.Background".
/// </summary>
/// <param name="dispatcherToPause"></param>
public static void DoEvents(Dispatcher dispatcherToPause)
{
SD.MainThread.VerifyAccess();
dispatcherToPause.Invoke(DispatcherPriority.Background, new System.Action(() => { }));
}
}
}

39
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/Helpers/VisualHelper.cs

@ -489,44 +489,5 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.Helpers @@ -489,44 +489,5 @@ namespace ICSharpCode.Data.EDMDesigner.Core.UI.Helpers
else
return GetVisualParentObject(parent, walkThroughPopupRoot, comparePredicate);
}
/// <summary>
/// Runs an Action in the current dispatcher.
/// </summary>
/// <param name="actionToRun"></param>
public static void RunInDispatcher(Action actionToRun)
{
if (Application.Current != null)
RunInDispatcher(Application.Current.Dispatcher, actionToRun);
}
/// <summary>
/// Runs an Action in a given dispatcher.
/// </summary>
/// <param name="dispatcher"></param>
/// <param name="actionToRun"></param>
public static void RunInDispatcher(Dispatcher dispatcher, Action actionToRun)
{
dispatcher.Invoke(DispatcherPriority.Background, actionToRun);
}
/// <summary>
/// Runs through all items in the dispatcher.
/// </summary>
public static void DoEvents()
{
if (Application.Current != null)
DoEvents(Application.Current.Dispatcher);
}
/// <summary>
/// Gives DispatcherFrames of the given Dispatcher priority, if
/// their DispatcherPriority is higher than "DispatcherPriority.Background".
/// </summary>
/// <param name="dispatcherToPause"></param>
public static void DoEvents(Dispatcher dispatcherToPause)
{
dispatcherToPause.Invoke(DispatcherPriority.Background, new System.Action(() => { }));
}
}
}

2
src/Main/Base/Project/Src/Project/Behaviors/DefaultProjectBehavior.cs

@ -106,7 +106,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -106,7 +106,7 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(
System.Windows.Threading.DispatcherPriority.Background,
System.Windows.Threading.DispatcherPriority.Loaded,
new Action(
delegate {
NavigationService.SuspendLogging();

2
src/Main/SharpDevelop/Workbench/AvalonPadContent.cs

@ -83,7 +83,7 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -83,7 +83,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
if (isFocused) {
IInputElement initialFocus = padInstance.InitiallyFocusedControl as IInputElement;
if (initialFocus != null) {
Dispatcher.BeginInvoke(DispatcherPriority.Input,
Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
new Action(delegate { Keyboard.Focus(initialFocus); }));
}
}

2
src/Main/SharpDevelop/Workbench/AvalonWorkbenchWindow.cs

@ -55,7 +55,7 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -55,7 +55,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
internal static void SetFocus(ManagedContent m, Func<IInputElement> activeChildFunc, bool forceSetFocus = false)
{
m.Dispatcher.BeginInvoke(
DispatcherPriority.Input,
DispatcherPriority.Loaded,
new Action(
delegate {
// ensure that condition for FocusContent() is still fulfilled

Loading…
Cancel
Save