“Not Responding” in window title when running in new process

前端 未结 8 1395
清酒与你
清酒与你 2021-02-07 14:39

I have a long running method that must run on UI thread. (Devex - gridView.CopyToClipboard())

I do not need the UI to be responsive while c

8条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 15:22

    This is because you call a long running method synchronously in your main application thread. As your applicaton is busy it does not respond to messages from windows and is marked as (Not Responding) until finished.

    To handle this do your copying asynchronously e.g. using a Task as one simplest solution.

    Task task = new Task(() =>
            {
                gridView.Enabled = false;
                gridView.CopyToClipboard();
                gridView.Enabled = true;
            });
    
            task.Start();
    

    Disable your grid so nobody can change values in the GUI. The rest of your application remains responsive (may has side effects!).

提交回复
热议问题