Tuesday, August 16, 2011

How to handle blocked Clipboard - Clipboard.Clear() Error

How to handle blocked Clipboard

Exception : The Clipboard could not be cleared.

This typically occurs when the Clipboard is being used by another process.


Solution for this is, retry the clear() again after a delay.

private void ClearClipBoard()
{
  try
  {
     System.Threading.Thread.Sleep(10000);
     Clipboard.Clear();
  }
  catch (Exception ex)
 {
     ClearClipBoard();
  }
}

No comments:

Post a Comment