Browse Source

Add a "DoEvents" call to the workaround for SD2-426.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@430 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
6a84cddd57
  1. 23
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs
  2. 15
      src/Main/Core/Project/Src/Util/ClipboardWrapper.cs

23
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs

@ -87,10 +87,27 @@ namespace ICSharpCode.TextEditor
dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea)); dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));
} }
OnCopyText(new CopyTextEventArgs(str)); OnCopyText(new CopyTextEventArgs(str));
Clipboard.SetDataObject(dataObject, true, 50, 50);
return true; // Work around ExternalException bug. (SD2-426)
// Best reproducable inside Virtual PC.
// SetDataObject has "retry" parameters, but apparently a call to "DoEvents"
// is necessary for the workaround to work.
int i = 0;
while (true) {
try {
Clipboard.SetDataObject(dataObject, true, 5, 50);
return true;
} catch (ExternalException) {
if (i++ > 5)
throw;
}
System.Threading.Thread.Sleep(50);
Application.DoEvents();
System.Threading.Thread.Sleep(50);
}
} else {
return false;
} }
return false;
} }
public void Cut(object sender, EventArgs e) public void Cut(object sender, EventArgs e)

15
src/Main/Core/Project/Src/Util/ClipboardWrapper.cs

@ -19,6 +19,7 @@ namespace ICSharpCode.Core
public static bool ContainsText { public static bool ContainsText {
get { get {
try { try {
LoggingService.Debug("ContainsText called");
return Clipboard.ContainsText(); return Clipboard.ContainsText();
} catch (ExternalException) { } catch (ExternalException) {
return false; return false;
@ -55,7 +56,19 @@ namespace ICSharpCode.Core
public static void SetDataObject(object data) public static void SetDataObject(object data)
{ {
Clipboard.SetDataObject(data, true, 50, 50); int i = 0;
while (true) {
try {
Clipboard.SetDataObject(data, true, 5, 50);
return;
} catch (ExternalException) {
if (i++ > 5)
throw;
}
System.Threading.Thread.Sleep(50);
Application.DoEvents();
System.Threading.Thread.Sleep(50);
}
} }
} }
} }

Loading…
Cancel
Save