Posts

Delegates Callback With Threading

    Private Delegate Sub AddValueToList(Value As Integer)     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click         Dim Thrd As New Threading.Thread(AddressOf StartProcess)         Thrd.Start()     End Sub       Private Sub StartProcess()         Dim RP As New RunningProcess         Dim X As Boolean = RP.SomeLongRunningProcessWithCallBack(AddressOf GetCallBackDelegateValue)     End Sub     Private Sub GetCallBackDelegateValue(Value As Integer)         ListBox1.Invoke(New AddValueToList(AddressOf AddValueToListBoxControl), Value)     End Sub Public Class RunningProcess     Public Delegate Sub CallBackDelegate(Value As Integer)     Public Function SomeLongRunningProcessWithCallBack(Current As CallBackDelegate)       ...

Delegate and Callback

Call Back With Delegate Explained Public Class Form1     Private Sub Button1_Click(sender As Object , e As EventArgs ) Handles Button1.Click         Dim RP As New RunningProcess         RP.SomeLongRunningProcess()         'With Above Logic We can;t get Update from Loop inside.Means Proceess which is Inside will not        able to update to 'Current Click Event which File is been Processed or File is been Downloaded or        Email is been Sent. 'Which record of Database is been Processed         'To Over come this Issue DELEGATE can be used with CallBack feature of Delegate.         Dim X As Boolean = RP.SomeLongRunningProcessWithCallBack( AddressOf GetCallBackDelegateValue)     End S...

Real Time Interface - 2

Image
Why use Interface Code : Public Interface IStorage     Function Save() As Boolean     Function Load() As Boolean End Interface Public Class DBStorage     Implements IStorage     Public Function Load() As Boolean Implements IStorage .Load         Console .WriteLine( "Trigger from DBStorage : Load " )         Return True     End Function     Public Function Save() As Boolean Implements IStorage .Save         Console .WriteLine( "Trigger from DBStorage : Save " )         Return True     End Function End Class Public Class FileStorage     Implements IStorage     Public Function Load() As Boolean Implements IStorage .Load   ...