Hello, I am quite new to VB and I need some help with threading. I've written my own status bar code (it doesn't do it on how far something has got, it just goes for the hell of it) but when I build it, all the other items on the form go see-through (they don't appear, just leave a hole in the form). After searching through lots of forums and what not, I thought threading might be the answer so that the other things load first before the status bar. So far I'm stuck on creating a new thread. My current code is:
Dim
thread1 As New System.Threading.Thread(AddressOf UserControl1_Paint)My status bar has been made completely out of e.graphics and so I thought that if I have a thread for my usercontrol paint and the form it accompanies, I should be able to set the priorites so that the form loads first, then the status bar.
After writing that code, i get the error:
Error 1 Overload resolution failed because no accessible 'New' can be called with these arguments:
'Public Sub New(start As System.Threading.ParameterizedThreadStart)': Method 'Private Sub UserControl1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)' does not have the same signature as delegate 'Delegate Sub ParameterizedThreadStart(obj As Object)'.
'Public Sub New(start As System.Threading.ThreadStart)': Method 'Private Sub UserControl1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)' does not have the same signature as delegate 'Delegate Sub ThreadStart()'. D:\Documents and Settings\ben\Local Settings\Application Data\Temporary Projects\WindowsApplication1\UserControl1.vb 10 13 WindowsApplication1
Please Help!!

VB Threading
Sri Harsha
hisham_abu
When you create a thread as you are, the signature (argument types and order) of the method you want it to start at needs to match the expected format as defined by ThreadStart or ParameterizedThreadStart, neither of which I’d bet does UserControl1_Paint match.
While I do not know your code at all, I would bet good money that you really don’t want to be calling the user controls paint event handler over and over again so it can do its work, instead if you want it to paint there are better ways, such as calling Invalidate() on the control or a region.
That being said though, from your description it doesn’t sound like your issue is with something not being drawn but instead by something transparent being drawn or something else that is causing the sections of your form to be transparent as you described.
In order to solve that problem, could you describe a bit more of what you are trying to do in the first place and maybe post some code
gilb12
Kryten
I agree with nobugz. I think there's sort of a hint that when a beginner wants to use multiple threads, there's something more fundamental wrong in the solution path.
Sleep(N) is rarely a good idea. Multiple threads to take care of sleep is also not a good idea.
Marin Millar