How to make a function trigger a callback in VB.net

I am afraid that I was Google, but cannot find an answer that I understand or can use.

In Javascript, you can run the function and set the callback function that it calls after the first function starts:

function doThis(callBack){ // do things // do things if(callBack){ callBack(); } } 

Call: doThis(function () { alert("done") });

So, after he has finished doing something, he triggers a warning to inform you of this.

But how do you do the same server side in VB.NET?

+6
callback
source share
1 answer

Just create a method that takes an Action delegate as a parameter:

 Sub DoThis(callback as Action) 'do this 'do that If Not callback Is Nothing Then callback() End If End Sub 

and you can call it like

 DoThis(Sub() Console.WriteLine("via callback!")) 
+6
source share

All Articles