| | |
VB.NET Threading or Backgroundworker ?? Struggling to get them to work
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
Ok,
What you want to do is create a Delegate Sub like this:
Delegate Sub LengthyProcessCallback()
In the beginning of the code for the event handler function add this:
I hope this makes more sense to you in the context of your app.
What you want to do is create a Delegate Sub like this:
Delegate Sub LengthyProcessCallback()
In the beginning of the code for the event handler function add this:
'Test to see if the correct thread is being used. If not, InvokeRequired will be true.
If Me.lblFilename1.InvokeRequired Then
'If InvokeRequired = True then this function will be re-called from the UI Thread.
Dim d As New LengthyProcessCallback(AddressOf ThisFunction)
Me.Invoke(d)
Else
Continue normal processing
End IfI hope this makes more sense to you in the context of your app.
•
•
Join Date: Jan 2008
Posts: 16
Reputation:
Solved Threads: 0
Could yoo expand on that a little more. Sorry, I'm being realy dense with this.
Where doe the Delegate Sub....... need toi go in the code?
And the remainder of the code you have listed, where does that go and what do I need to replace ThisFunction with?
Incidently, my lengthy process is called LoadData and I tried raining the event FinishedDataLoading. But that's as far I got and then I had trouble with
Do you have a simple example?
Thanks for your help.
Andrew
Where doe the Delegate Sub....... need toi go in the code?
And the remainder of the code you have listed, where does that go and what do I need to replace ThisFunction with?
Incidently, my lengthy process is called LoadData and I tried raining the event FinishedDataLoading. But that's as far I got and then I had trouble with
Do you have a simple example?
Thanks for your help.
Andrew
The Delegate Sub can be put anywhere within the Class declaration, but not within another Sub or Function.
The name of the EventHandler Function should replace ThisFunction. In other words,
the name of the function that is being called when the Event is being raised.
The remainder of the code would go into the beginning of the EventHandler function like this:
The name of the EventHandler Function should replace ThisFunction. In other words,
the name of the function that is being called when the Event is being raised.
The remainder of the code would go into the beginning of the EventHandler function like this:
Public Sub EventHandler()
'Test to see if the correct thread is being used. If not, InvokeRequired will be true.
If Me.lblFilename1.InvokeRequired Then
'If InvokeRequired = True then this function will be re-called from the UI Thread.
Dim d As New LengthyProcessCallback(AddressOf ThisFunction)
Me.Invoke(d)
Else
Place your code here from the EventHandler Function
End If
End Sub![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Randomize A Chosen
- Next Thread: Enable Menu items
Views: 10772 | Replies: 12
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net .net2005 30minutes 2008 access add application array assignment basic binary box button buttons center code connectionstring convert cpu data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dll dosconsolevb.net editvb.net employees error excel exists firewall folder function image images isnumericfuntioncall listview login math memory mobile module msaccess mssqlbackend mysql navigate net opacity page pan peertopeervideostreaming picturebox plugin port print printing printpreview problem record refresh reports" reuse save savedialog search serial sorting sql sqldatbase storedprocedure string structures studio temp textbox timer upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet vista visual visualbasic visualbasic.net visualstudio2008 web wpf xml





