当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Waiting on Mainthread while continuing processing on UI

问题描述:

When working with console applications, Console.Readline relinquishes processing to the UI from the Main thread and only continues when an event, such as the pressing of the enter button is fired. How do I replicate this functionality (With a Window form as the UI in this case) in windows form application?

网友答案:

You cannot do this directly.

However, you can do it by calling Invoke, as I described here.

网友答案:

Use form.ShowDialog() instead of form.Show()

This will not stop the thread, but it will stop the user from doing other things in the UI until the window is closed.

网友答案:

Now that you have explained what you want to do...

It would be better to use a BackgroundWorker, keep the GUI active, but disabled and presenting a progress bar + cancel button, until done.

分享给朋友:
您可能感兴趣的文章:
随机阅读: