@ -88,21 +88,38 @@ namespace ICSharpCode.TextEditor
}
}
OnCopyText ( new CopyTextEventArgs ( stringToCopy ) ) ;
OnCopyText ( new CopyTextEventArgs ( stringToCopy ) ) ;
// Work around ExternalException bug. (SD2-426)
SafeSetClipboard ( dataObject ) ;
// Best reproducable inside Virtual PC.
try {
Clipboard . SetDataObject ( dataObject , true , 1 0 , 5 0 ) ;
} catch ( ExternalException ) {
Application . DoEvents ( ) ;
try {
Clipboard . SetDataObject ( dataObject , true , 1 0 , 5 0 ) ;
} catch ( ExternalException ) { }
}
return true ;
return true ;
} else {
} else {
return false ;
return false ;
}
}
}
}
// Code duplication: TextAreaClipboardHandler.cs also has SafeSetClipboard
[ThreadStatic] static int SafeSetClipboardDataVersion ;
static void SafeSetClipboard ( object dataObject )
{
// Work around ExternalException bug. (SD2-426)
// Best reproducable inside Virtual PC.
int version = unchecked ( + + SafeSetClipboardDataVersion ) ;
try {
Clipboard . SetDataObject ( dataObject , true ) ;
} catch ( ExternalException ) {
Timer timer = new Timer ( ) ;
timer . Interval = 1 0 0 ;
timer . Tick + = delegate {
timer . Stop ( ) ;
timer . Dispose ( ) ;
if ( SafeSetClipboardDataVersion = = version ) {
try {
Clipboard . SetDataObject ( dataObject , true , 1 0 , 5 0 ) ;
} catch ( ExternalException ) { }
}
} ;
timer . Start ( ) ;
}
}
bool CopyTextToClipboard ( string stringToCopy )
bool CopyTextToClipboard ( string stringToCopy )
{
{