WinForm Application UI Hangs during Long-Running Operation

前端 未结 3 1555
梦毁少年i
梦毁少年i 2020-11-22 05:13

I have a windows forms application on which I need to use a for loop having a large number of Remote Calls around 2000 - 3000 calls,

and while executing the for loop

3条回答
  •  温柔的废话
    2020-11-22 05:31

        private voidForm_Load(object sender, EventArgs e)
        {
            MethodInvoker mk = delegate
            {
                //your job
            };
            mk.BeginInvoke(callbackfunction, null);
        }
    
        private void callbackfunction(IAsyncResult res)
        {
            // it will be called when your job finishes.
        }
    

    use MethodInvoker is the easiest way.

提交回复
热议问题