diff --git a/JL.Windows/GUI/MainWindow.xaml.cs b/JL.Windows/GUI/MainWindow.xaml.cs index 63bd5cb5..3e4c788b 100644 --- a/JL.Windows/GUI/MainWindow.xaml.cs +++ b/JL.Windows/GUI/MainWindow.xaml.cs @@ -106,7 +106,7 @@ protected override async void OnSourceInitialized(EventArgs e) if (CoreConfigManager.CaptureTextFromClipboard) { s_clipboardSequenceNo = WinApi.GetClipboardSequenceNo(); - _ = CopyFromClipboard(); + _ = await CopyFromClipboard().ConfigureAwait(true); } FirstPopupWindow.Owner = this; @@ -122,7 +122,7 @@ protected override async void OnSourceInitialized(EventArgs e) await WindowsUtils.InitializeMainWindow().ConfigureAwait(false); } - private bool CopyFromClipboard() + private async Task CopyFromClipboard() { bool gotTextFromClipboard = false; while (Clipboard.ContainsText() && !gotTextFromClipboard) @@ -137,6 +137,7 @@ private bool CopyFromClipboard() catch (ExternalException ex) { Utils.Logger.Warning(ex, "CopyFromClipboard failed"); + await Task.Delay(5).ConfigureAwait(true); } } @@ -250,7 +251,7 @@ private async void ClipboardChanged(object? sender, EventArgs? e) } s_clipboardSequenceNo = currentClipboardSequenceNo; - bool gotTextFromClipboard = CopyFromClipboard(); + bool gotTextFromClipboard = await CopyFromClipboard().ConfigureAwait(true); if (gotTextFromClipboard && ConfigManager.AutoLookupFirstTermWhenTextIsCopiedFromClipboard