Application.Current.Dispatcher.BeginInvoke - 在哪里放置 Try &抓住? [英] Application.Current.Dispatcher.BeginInvoke - Where to place Try & catch?

查看:58
本文介绍了Application.Current.Dispatcher.BeginInvoke - 在哪里放置 Try &抓住?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个像这样在后台调用的调度程序:

if I have a dispatcher invoking in background like this:

Application.Current.Dispatcher.BeginInvoke(new Action(() => MethodToCall()), DispatcherPriority.Background);

我应该将上面的代码包装在 Try & 中吗?捕捉或放置 try &在 MethodToCall() 方法中捕获?

Should I have wrap the code above inside a Try & catch or place the try & catch inside the MethodToCall() method?

非常感谢,

推荐答案

如果你真的有捕捉特定异常的案例,那么 try { } catch 应该是放在 MethodToCall 内.

If you really have a case for catching a specific exception then the try { } catch should be placed inside MethodToCall.

这篇关于Application.Current.Dispatcher.BeginInvoke - 在哪里放置 Try &抓住?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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