Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I dynamically call a function with delegates by passing a string to a background thread in VB.NET?
    text
    copied!<p>How do I dynamically call a function with delegates by passing a string to a background thread in VB.NET?</p> <p>Currently my code is this</p> <pre><code>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 </code></pre> <p>and ultimately it will raise an event to give me my result.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload