使C#应用程序从不响应状态进入优先状态 [英] Preveting C# application from going to not responding state

查看:414
本文介绍了使C#应用程序从不响应状态进入优先状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试对数据库进行读/写操作时,我都有一个C#应用程序,该应用程序进入不响应状态,因此我无法做任何事情,只能等待它完成,有时它会崩溃.那么我该怎么做才能停止这种状态?

i have a C# application whenever i try i read/write to database the application go to not responding state so i can not do anything but wait for it to finish and some times it crashes. So what i can do to stop this state?

推荐答案

为此使用单独的线程.在每个线程的顶部捕获所有异常,并使用Control.Invoke通知主UI线程每个异常.
—SA
Use a separate thread for it. On top of each thread catch all exceptions and notify main UI thread on every exception using Control.Invoke.

—SA


这篇关于使C#应用程序从不响应状态进入优先状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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