I have a problem getting clipboard text via the async method. Because it always returns an empty value (while it's not empty). This is a simple demonstration of the problem:
private async void button_Click(object sender, EventArgs e)
{
string result = await Task<string>.Run(() =>
{
System.Threading.Thread.Sleep(3000);
return Clipboard.GetText(); //returns empty! (but clipboard is not empty)
});
MessageBox.Show(result);
}
I'm sure that the clipboard is not empty. what's the solution?