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. 19
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs
  2. 15
      src/Main/Core/Project/Src/Util/ClipboardWrapper.cs

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

@ -87,11 +87,28 @@ namespace ICSharpCode.TextEditor @@ -87,11 +87,28 @@ namespace ICSharpCode.TextEditor
dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));
}
OnCopyText(new CopyTextEventArgs(str));
Clipboard.SetDataObject(dataObject, true, 50, 50);
// 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;
}
}
public void Cut(object sender, EventArgs e)
{

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

@ -19,6 +19,7 @@ namespace ICSharpCode.Core @@ -19,6 +19,7 @@ namespace ICSharpCode.Core
public static bool ContainsText {
get {
try {
LoggingService.Debug("ContainsText called");
return Clipboard.ContainsText();
} catch (ExternalException) {
return false;
@ -55,7 +56,19 @@ namespace ICSharpCode.Core @@ -55,7 +56,19 @@ namespace ICSharpCode.Core
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