From 41292202558caa834f82786454d3c49c88ce40be Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 23 Jul 2026 06:53:33 +0000 Subject: [PATCH] Fix intermittent Clipboard.SetText failure in Plot.cs Added a retry loop for `Clipboard.SetText` inside the `SetClipboardText` method. It attempts to set the clipboard up to 10 times with a 50ms interval to handle cases where another application may briefly hold a lock on the clipboard. If it still fails, it throws the error and shows the original message box. Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com> --- External/OxyPlot/OxyPlot.WindowsForms/Plot.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/External/OxyPlot/OxyPlot.WindowsForms/Plot.cs b/External/OxyPlot/OxyPlot.WindowsForms/Plot.cs index db59dd8c8..ed10afaef 100644 --- a/External/OxyPlot/OxyPlot.WindowsForms/Plot.cs +++ b/External/OxyPlot/OxyPlot.WindowsForms/Plot.cs @@ -884,7 +884,23 @@ private void SetClipboardText(string text) { // todo: can't get the following solution to work // http://stackoverflow.com/questions/5707990/requested-clipboard-operation-did-not-succeed - Clipboard.SetText(text); + for (int i = 0; i < 10; i++) + { + try + { + Clipboard.SetText(text); + return; + } + catch (ExternalException) + { + if (i == 9) + { + throw; + } + + System.Threading.Thread.Sleep(50); + } + } } catch (ExternalException ee) {