How to continue executing code after calling ShowDialog()

后端 未结 7 808
走了就别回头了
走了就别回头了 2020-12-17 10:58

the Form.ShowDialog() method causes the code to be halted until the newly called form is closed. I need the code to continue running after the ShowDialog() method is called.

7条回答
  •  情歌与酒
    2020-12-17 11:36

    • If you just want the code to continue on instead of blocking until the popup is closed consider using Show instead of ShowDialog.

    • If you have some action that you want to have the parent form doing while the child form is up, then yes, it could be appropriate to use a BackgroundWorker (or just manually starting a new Thread/Task). It would be helpful to know more about what that task is though. If you need to interact with the main form, or the child form, then that seems like trouble to me; if you just need to do some background task with no UI interaction then this is the right line of thought.

    • Another possibility is that what you want to do really just should be something done in the child form, rather than the parent form.

提交回复
热议问题