How do i dynamically call a function with delegates by passing a string to a background thread in vb2005.net?
currently my code is this
Public Sub invertImageBK(ByVal image As Bitmap)
Dim snxl As System.ComponentModel.BackgroundWorker = createBW()
snxl.RunWorkerAsync(New ImageProperties(image.Clone, "invertImage", Nothing))
End Sub
Public Sub grayscaleImageBK(ByVal image As Bitmap)
Dim snxl As System.ComponentModel.BackgroundWorker = createBW()
snxl.RunWorkerAsync(New ImageProperties(image.Clone, "grayscaleImage", Nothing))
End Sub
Public Sub colorizeImageBK(ByVal image As Bitmap, ByVal colorize As Color)
Dim snxl As System.ComponentModel.BackgroundWorker = createBW()
snxl.RunWorkerAsync(New ImageProperties(image.Clone, "colorizeImage", colorize))
End Sub
Private Sub ConvertImage(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
If e.Argument.extra IsNot Nothing Then
Dim snxl As New twoarg()
Else
End If
End Sub
Private Delegate Function onearg(ByVal image As Bitmap) As Bitmap
Private Delegate Function twoarg(ByVal image As Bitmap, ByVal altcolor As Color) As Bitmap
Private Function createBW() As System.ComponentModel.BackgroundWorker Dim cbs As New System.ComponentModel.BackgroundWorker AddHandler cbs.DoWork, AddressOf ConvertImage Return cbs End Function
Public Structure ImageProperties Dim img As Bitmap Dim filt As String
Public Sub New(ByVal image As Bitmap, ByVal filter As String, ByVal extra As Object)
img = image.Clone
filt = filter
End Sub
End Structure
and ultimatly in the end it will raise an event to give me my result.