1

Simple question: How does this translate to VB.Net

Dispatcher.BeginInvoke(() => listening = false);

listening is a variable on the class (boolean). Converters online didn't help and what we've come up didn't compile:

Dispatcher.BeginInvoke(Function(listening) listening = False)

Any help would be appreciated.

2
  • That would either not compile in C#, so please post the complete line. Mar 12, 2012 at 13:38
  • @TimSchmelter: apparantly ); slipped of, fixed now
    – Terry
    Mar 12, 2012 at 13:41

1 Answer 1

3

In a c# lambda like:

() => listening = false

the empty parentheses means that the lambda takes no parameters. And since Dispatcher.BeginInvoke takes an Action, having no return value, in VB this would be a Sub, not a Function:

Sub() listening = False

so you'd have:

Dispatcher.BeginInvoke(Sub() listening = False)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.