如何在vb.net中使用DispatcherOperationCallback
我在使用 DispatcherOperationCallback 将 c# 转换为 vb.net 时遇到问题。
我尝试根据 将 c# 匿名转换为 vb 的帮助来转换它。 net
我正在使用 VS2010。
我有这样的 c# 代码:
public void Callback(Contract contract)
{
Dispatcher.BeginInvoke(DispatcherPriority.Normal,
(DispatcherOperationCallback)delegate(object arg)
{
Contract obj = (Contract)arg;
txtRequest.Text = HandleArgument(obj);
return null;
}, contract);
}
在我尝试像这样更改为 vb.net 之后,
Public Sub Callback(ByVal contract As Contract) Implements IServiceCallback.Callback
Dispatcher.BeginInvoke(New DispatcherOperationCallback(Sub(arg As Object)
txtRequest.Text = HandleArgument(DirectCast(arg, Contract))
End Sub), DispatcherPriority.Normal, contract)
End Sub
但它不起作用。 vs2010显示“嵌套子没有与委托兼容的签名“委托函数DispatcherOperationCallback(arg As Object) As Object”
谢谢您的帮助。
I have a problem with coverting c# to vb.net on using DispatcherOperationCallback.
I have tried to convert it based on help to convert c# anonymous to vb.net
I'm using VS2010.
I have a c# code like this:
public void Callback(Contract contract)
{
Dispatcher.BeginInvoke(DispatcherPriority.Normal,
(DispatcherOperationCallback)delegate(object arg)
{
Contract obj = (Contract)arg;
txtRequest.Text = HandleArgument(obj);
return null;
}, contract);
}
And After I tried to change to vb.net like this
Public Sub Callback(ByVal contract As Contract) Implements IServiceCallback.Callback
Dispatcher.BeginInvoke(New DispatcherOperationCallback(Sub(arg As Object)
txtRequest.Text = HandleArgument(DirectCast(arg, Contract))
End Sub), DispatcherPriority.Normal, contract)
End Sub
but it did not work. The vs2010 displayed "nested sub does not have a signature that is compatible with delegate "Delegate Function DispatcherOperationCallback(arg As Object) As Object"
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需阅读错误消息:
因此,您应该相应地更改代码。
Just read the error message:
so, you should change you code accordingly.