消息框上的工作线程 [英] MessageBox on worker thread

查看:84
本文介绍了消息框上的工作线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有一个工作线程做一些文件同步。



在一定条件下在同步过程中,我的工作线程需要做出决定继续或没有。所以,我想我会要求用户反馈通过显示一个对话框/消息框。(是/否)。 。这将导致工人继续或停止



现在的问题是:结果
是它的安全,以显示对非UI线程的消息框?结果
。将它有可能导致潜在的问题?


解决方案

是否安全展现在非UI线程的消息框?




是的,它是安全的。 MessageBox.Show()是一个静态的线程安全的方法。




将它可能造成的任何潜在的问题?




在此情况下,我认为。但是,你阻塞线程,不是你应该做的时候就可以阻止它。


My application has a worker thread doing some files synchronisation.

Under certain condition during the sync process, my worker thread needs to make a decision to continue or not. Hence, I think I would ask for user feedback by showing a dialog box/message box.. (Yes/No). Which would cause the worker to either continue or stop.

Now the question is:
Is it safe to show message box on non UI thread?
Would it possibly cause any potential issues?

解决方案

Is it safe to show message box on non UI thread ?

Yes it is safe. MessageBox.Show() is a static thread-safe method.

would it possibly cause any potential issues ?

Not in this scenario I think. But you do block a Thread, not something you should do when you can prevent it.

这篇关于消息框上的工作线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆