I am trying to write something in VB.NET based on a C# solution that I have. In the C# solution I call the function with:
somefunction(s => Console.WriteLine(s)).Wait();
And the called method is:
public static Task somefuntion(Action<string> callback);
In VB.NET I have
somefunction(Function(s) Console.WriteLine(s)).Wait()
Public Shared somefunction(ByRef callback As Action(Of string)) As Task
Any ideas what I am doing wrong?
ByRefis probably not what you want unlesssomefunctionmight provide its own callback back to the caller (which doesn't appear to be happening here).ByValis probably what you want. TheByRef/ByValdistinction is somewhat confusing with reference types, where it refers to whether the host variable passed as an argument might be re-pointed to a different object, rather than whether a copy of the object is passed.