• Log in or sign up for an account here: https://www.sythe.org/login

True multithreading

TheDarkExistence

Newcomer
Joined
Jul 4, 2009
Sythe Gold
0
Messages
12
Alright so I've created a Grand Exchange parser and all the info gets pumped into a listview...Now I don't want the app to freeze while the shit is being loaded, so I tried to multithread, but I don't think I'm doing it right. I tried adding a new thread then putting my instructions into that thread, but then I'd get CrossThreadException errors or something like that, because the thread was trying to reference an object outside of itself (the listview). So, I then checked to see if the form required an invoke, and if it did, to do it to try and remove the error:
Code:
If Me.InvokeRequired = True Then
Me.Invoke(New MethodInvoker(AddressOf ParseGE()))
Else
ParseGE()
End If

So now I don't get the error, but it's as though there was no thread added at all in the first place since the application still freezes. I've also tried using the BackgroundProcess object but nothing seems to be working! Please help :(
 
Code:
Private Sub ParseGe()
If Me.InvokeRequired = True Then
Me.Invoke(New MethodInvoker(AddressOf ParseGE))
Else

'CODE YOU WANT TO INVOKE GOES HERE

End If
End Sub

You only need to invoke when you are accessing a control on your form. Processes do not need to be invoked.

For example:
You might want to use a loop to do a process on an array of integers (maybe times each integer by 2) and then display them in a listview. The process can be done on a different thread but as your form is working on a different thread to your process controls cannot be accessed unless you invoke. So when the loop adds the integers to the listview you must invoke so that the control can be accessed from the other thread.
 
Runescape Gamblingrunescape gambling
Back
Top