Browse Source

Fix SD2-1638: Unable to re-open SharpDevelop's window under Vista after minimizing

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5731 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
2df23b5ee4
  1. 14
      src/Main/Base/Project/Src/TextEditor/ClipboardHandling.cs

14
src/Main/Base/Project/Src/TextEditor/ClipboardHandling.cs

@ -5,11 +5,14 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using ICSharpCode.SharpDevelop.Util;
using System; using System;
using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using ICSharpCode.Core.WinForms; using ICSharpCode.Core.WinForms;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Util;
using Microsoft.Win32.SafeHandles;
namespace ICSharpCode.SharpDevelop.DefaultEditor namespace ICSharpCode.SharpDevelop.DefaultEditor
{ {
@ -65,9 +68,16 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor
} }
currentWorker = workerThread.Enqueue(DoUpdate); currentWorker = workerThread.Enqueue(DoUpdate);
// wait a few ms in case the clipboard can be accessed without problems // wait a few ms in case the clipboard can be accessed without problems
currentWorker.AsyncWaitHandle.WaitOne(50); WaitForSingleObject(currentWorker.AsyncWaitHandle.SafeWaitHandle, 50);
// Using WaitHandle.WaitOne() pumps some Win32 messages.
// To avoid unintended reentrancy, we need to avoid pumping messages,
// so we directly call the Win32 WaitForSingleObject function.
// See SD2-1638 for details.
} }
[DllImport("kernel32", SetLastError=true, ExactSpelling=true)]
static extern Int32 WaitForSingleObject(SafeWaitHandle handle, Int32 milliseconds);
static void DoUpdate() static void DoUpdate()
{ {
clipboardContainsText = ClipboardWrapper.ContainsText; clipboardContainsText = ClipboardWrapper.ContainsText;

Loading…
Cancel
Save