How to handle a blocked clipboard and other oddities

前端 未结 8 2016
闹比i
闹比i 2020-12-02 10:03

Over the course of the last couple of hours I have been tracking down a fairly specific bug with that occurs because another application has the clipboard open. Essentially

8条回答
  •  借酒劲吻你
    2020-12-02 10:18

    Another workaround would be to use Clipboard.SetDataObject instead of Clipboard.SetText.

    According to this MSDN article this method has two parameters - retryTimes and retryDelay - that you can use like this:

    System.Windows.Forms.Clipboard.SetDataObject(
        "some text", // Text to store in clipboard
        false,       // Do not keep after our application exits
        5,           // Retry 5 times
        200);        // 200 ms delay between retries
    

提交回复
热议问题