Running a windows form in a separate thread

前端 未结 4 1386
孤独总比滥情好
孤独总比滥情好 2021-01-15 02:10

I am dealing with running a control in a form, however the form itself is of no value to me. I essentially want the form to run a task and return a value, however for that I

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-15 03:00

    I've got two ideas in my mind:

    1. Run delegate method

      IAsyncResult ar = del.BeginInvoke(callback, state);

      ... do the task

      EndInvoke(ar); // waiting for task result if you allow to wait

    2. Separate thread

    The best way may be use separate thread to do the task and call delegate in this thread to inform main thread about work finish.

    edit: or Worker like suggest my predecessor

提交回复
热议问题