473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Form.Label.Invoke method not working

Here is my basic problem. I have a form that executes a
cpu instensive algorithm occupying the first thread. When
the algorithm is executed another form pops up telling the
user the progress that has been made.
Whenever I attempt to update my frmProgress, the events
are 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 reach
a 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("Openin g"))
Extract(filename)

filename.Open

UploadForm.Label.Invoke(UpdateField.Invoke("Extrac ting
Text 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
Jul 19 '05 #1
1 4049
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
.

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Skippytpe | last post by:
Does anyone have an idea why the form validation in the following page wouldn't be working? I had been using XHTML 1.0 transitional which allowed me to use the form attribute 'name.' I could then...
10
by: Drakier Dominaeus | last post by:
This is my first time posting here, so please forgive me if I do anything incorrectly. I've been learning C# and working with different things and decided I wanted to get into Multi-Threading....
4
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just...
0
by: Venus | last post by:
Hello, After trying some ways to do it I wanted to use something like the code below but for some reason is not working (I have to generate the entire form dynamically (not only the controls)):...
1
by: John Altland | last post by:
Here is my basic problem. I have a form that executes a cpu instensive algorithm occupying the first thread. When the algorithm is executed another form pops up telling the user the progress that...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
7
by: ChrisM | last post by:
Hi, I'm trying to get my head round Async. procedure calls. I have the following code: delegate double GetLabourWIPDelegate(DateTime reqDate); .... GetLabourWIPDelegate...
9
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form...
2
by: punitshrivastava | last post by:
Hi to All. I am Punit Shrivastava.I am working in Asp.As i am new in this technology please help me. I want to create enquiry form in Asp. For this i code like this: <form name="enquiry"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.