Since this is only a snippet of code, I can't tell if
you've put this together the right way. But, the standard
way of working with threads and the UI is to use a
Worker - Controller - Client pattern. To see a great
example of this and a good explanation, look at Rocky
Lhotka's article on MSDN:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnadvnet/html/vbnet09272002.asp
Using this example should do the trick for you.
Jeff Levinson
Author of "Building Client/Server Applications with
VB.NET: An Example Driven Approach"
-----Original Message-----
Here is my basic problem. I have a form that executes
acpu instensive algorithm occupying the first thread.
Whenthe algorithm is executed another form pops up telling
theuser the progress that has been made.
Whenever I attempt to update my frmProgress, the
eventsare put placed at the end of the thread's queue and
executed after my algorithm is finished. Using the
frmProgress.Label.Invoke method with delagates, I have
heard would fix this problem, however I have yet to
reacha resolution. Can anyone help me out. Here is the code.
Delegate Sub UpdateDelegate(ByVal updatefield As String)
Delegate Sub PaintForm()
Public Sub TextExtractor
Dim UploadForm As New UploadConfirm
Dim UpdateField As UpdateDelegate
Dim PF As PaintForm
PF = AddressOf UploadForm.Show
PF.Invoke()
UpdateField = AddressOf UploadForm.UpdateLabel
UploadForm.Label.Invoke(UpdateField.Invoke
("Opening")) Extract(filename)
filename.Open
UploadForm.Label.Invoke(UpdateField.Invoke
("ExtractingText from file"))
Dim str As String = GetText(filename)
UploadForm.Label.Invoke(UpdateField.Invoke("Sendin g
Text to Database") )
SendToDB(str)
UploadForm.Label.Invoke(UpdateField.Invoke("Finish ed
Uploading File"))
filename.Close
End Sub
.....
End Class
Class UploadConfirm
....
Public Sub UpdateLabel(ByVal str As String)
Me.Label.Text = str
End Sub
....
End Class
Thanks for any help
.