I try to implement a C# program in VB.NET and I've stuck on a point. I would like to get the exact equivalent. I could not find out how to pass an event to a sub or function in the following way. So the part which I cannot do in vb.net is var mediaOpenedHandler = MediaOpened;
. In VB you cannot pass an event like this. If I write in VB: Dim mediaOpenedHandler = MediaOpened
then it says "'Public Event MediaOpened()' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event." So how can I get exactly the same result. Thanks in advance.
public abstract class MediaPlayerBase : WorkDispatcherObject
{
…
public event Action MediaOpened;
…
protected void InvokeMediaOpened()
{
var mediaOpenedHandler = MediaOpened;
if (mediaOpenedHandler != null)
mediaOpenedHandler();
}
}