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

前端 未结 8 1286
清酒与你
清酒与你 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:19

    I am afraid the simplest solution is to make your own CopyToClipboard() where you in your for loop, every now and then, do an Application.DoEvents, which keeps the ui thread responsive.

    I guess most licenses of DevExpress have the source code available, so you can probably copy paste most if it.

    Since you know the data you can probably make a much simpler procedure than the generic that DevExpress uses.

    like this:

    const int feedbackinterval = 1000;
    
    private void btnCopy_Click(object sender, EventArgs e)
    {
        StringBuilder txt2CB = new StringBuilder();
        int[] rows = gridView1.GetSelectedRows();
    
        if (rows == null) return;
    
        for (int n = 0; n < rows.Length; n++)
        {
            if ((n % feedbackinterval) == 0) Application.DoEvents();
    
            if (!gridView1.IsGroupRow(rows[n]))
            {
                var item = gridView1.GetRow(rows[n]) as vWorkOrder;
                txt2CB.AppendLine(String.Format("{0}\t{1}\t{2}",
                item.GroupCode, item.GroupDesc, item.note_no??0));
            }
         }
            Clipboard.SetText(txt2CB.ToString());
    }
    

提交回复
热议问题