[MWF] Fix hang if clipboard source application closes down (fixes #674098)
authorTom Hindle <tom_hindle@sil.org>
Tue, 30 Aug 2011 14:56:37 +0000 (16:56 +0200)
committerEberhard Beilharz <eb1@sil.org>
Fri, 28 Feb 2014 16:31:22 +0000 (17:31 +0100)
This change adds a timeout to the Clipboard.Enumerating loop, making a
hang less likely. This fixes Novell bug #674098
(https://bugzilla.novell.com/show_bug.cgi?id=674098).

mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs

index be2966157251a3edacf74110190c667537623fb2..2f3b9d85461287a98718c52431037c72e7d6c0f0 100644 (file)
@@ -2727,9 +2727,14 @@ namespace System.Windows.Forms {
                        while (f != null) {
                                XConvertSelection(DisplayHandle, CLIPBOARD, (IntPtr)f.Id, (IntPtr)f.Id, FosterParent, IntPtr.Zero);
 
+                               var timeToWaitForSelectionFormats = TimeSpan.FromSeconds(4);
+                               var startTime = DateTime.Now;
                                Clipboard.Enumerating = true;
                                while (Clipboard.Enumerating) {
                                        UpdateMessageQueue(null, false);
+
+                                       if (DateTime.Now - startTime > timeToWaitForSelectionFormats)
+                                               break;
                                }
                                f = f.Next;
                        }