I made a custom class to do stuff. I want the caller of the custom class to handle the 'write to the log'. What's the best way to do it?, do I need a eventhandler a delegate or a action?, how do I pass, save and call it in my custom class.
I've stripped my code down to this to explain my question;
Public Class Form1
Private Sub WriteToLog(LineToWrite As String) ' the local log writer
TextBox1.AppendText(LineToWrite & vbCrLf)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WriteToLog("Starting...")
Dim a As New Yadda(WriteToLog)
a.CalculateStuff()
End Sub
Public Class Yadda
Sub New(LogWriter As Delegate/eventhanlder/action?)
' save the event handler for the local log
how?
End Sub
Private Sub ClassWriteToLog(LineToWrite As String) ' the logwriter in the class, who should pass the things to write to the local writer
'Call the passed event to write to the local event log
End Sub
Public Sub CalculateStuff()
For t As Integer = 1 To 100
For tt As Integer = 1 To 1000000
Dim a As Double = 17323 * 43764
Next
ClassWriteToLog("Processing step; " & t)
Next
End Sub
End Class
End Class