R
Roidy
OK bear with me while I try to explain
I'm writing a program where I need to do a lot of different background
worker tasks and display the progress in a dialog box. So rather than create
a separate dialog for each task I created a class that displays a dialog and
fires off a background worker, what I can't seem to do is pass a dowork
handler sub into the class. This is basically what I've got so far:-
MainForm code:-
........
Dim pBox as New ProgressBox("Test caption")
pBox.ShowDialog()
Sub worksub()
.........
Do background work here
.........
End Sub
........
Class code:-
Public Class ProgressBox
Public Sub New(ByVal txt as String)
InitProgBox()
Me.Label1.text = txt
Me.backgroundworker1.runWorkerAsync()
End Sub
Public Sub InitProgBox()
..........
..........
Code to set up the dialog and background worker
..........
..........
End Sub
End Class
I can happily pass string and other variables in to the class but when I
create a new instance of ProgressBox I need to be able to pass worksub into
it and have it added as the handler of the backgroundworkers DoWork
function. I just can't figure out how to pass worksub into the class along
the lines of:-
Dim pBox as New ProgressBox("Test caption", worksub)
Help please
Robert
I'm writing a program where I need to do a lot of different background
worker tasks and display the progress in a dialog box. So rather than create
a separate dialog for each task I created a class that displays a dialog and
fires off a background worker, what I can't seem to do is pass a dowork
handler sub into the class. This is basically what I've got so far:-
MainForm code:-
........
Dim pBox as New ProgressBox("Test caption")
pBox.ShowDialog()
Sub worksub()
.........
Do background work here
.........
End Sub
........
Class code:-
Public Class ProgressBox
Public Sub New(ByVal txt as String)
InitProgBox()
Me.Label1.text = txt
Me.backgroundworker1.runWorkerAsync()
End Sub
Public Sub InitProgBox()
..........
..........
Code to set up the dialog and background worker
..........
..........
End Sub
End Class
I can happily pass string and other variables in to the class but when I
create a new instance of ProgressBox I need to be able to pass worksub into
it and have it added as the handler of the backgroundworkers DoWork
function. I just can't figure out how to pass worksub into the class along
the lines of:-
Dim pBox as New ProgressBox("Test caption", worksub)
Help please
Robert