How to stop BackgroundWorker on Form's Closing event?

后端 未结 12 1856
春和景丽
春和景丽 2020-11-21 13:55

I have a form that spawns a BackgroundWorker, that should update form\'s own textbox (on main thread), hence Invoke((Action) (...)); call.
If in Handl

12条回答
  •  [愿得一人]
    2020-11-21 14:22

    Another way:

    if (backgroundWorker.IsBusy)
    {
        backgroundWorker.CancelAsync();
        while (backgroundWorker.IsBusy)
        {
            Application.DoEvents();
        }
    }
    

提交回复
热议问题