0
我想翻译下面的C#代码段VB:C#到VB.NET转换错误,建议要求
public bool ShowHandlerDialog(string message)
{
Message = message;
Visibility = Visibility.Visible;
_parent.IsEnabled = false;
_hideRequest = false;
while (!_hideRequest)
{
// HACK: Stop the thread if the application is about to close
if (this.Dispatcher.HasShutdownStarted ||
this.Dispatcher.HasShutdownFinished)
{
break;
}
// HACK: Simulate "DoEvents"
this.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { }));
Thread.Sleep(20);
}
return _result;
}
但翻译是在这一行给了一个错误:
this.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { }));
翻译是:
Me.Dispatcher.Invoke(DispatcherPriority.Background, New ThreadStart(Function() Do End Function))
这似乎并没有正确地转换新的ThreadStart后的位。可有人请解释什么是“delegate {}
”确实在
new ThreadStart(delegate {}));
,我怎么可能纠正翻译错误?感谢您的任何建议!
很好的答案,谢谢! – TripleAntigen