Threading?

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
17 posts Page 1 of 2
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Threading?
Dummy1912
Hello,

Seems my thread is only run 2x and then stops :(
anyone whats wrong?

'Form load
Code: Select all
        NewThread = New Thread(AddressOf Check0)
        NewThread.Start()


'Sub Check0
Code: Select all
        Me.Invoke(New Action(
          Sub()

              If status__.Text = 0 Then
                  GetStats()                  
              Else
                  GetStats()
              End If
          End Sub))
        Threading.Thread.Sleep(200)

it must run all the time and not just 2x
i even changed the sleep to 1000 but didn't do any different

anyone please?
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Threading?
mandai
You would need to add a loop to keep the thread running.
This can be added in the Check0 sub:
Code: Select all
    Sub Check0()

        While True

            Me.Invoke(New Action(
              Sub()

                  If status__.Text = 0 Then
                      GetStats()
                  Else
                      GetStats()
                  End If
              End Sub))
            Threading.Thread.Sleep(200)

        End While

    End Sub
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Threading?
Dummy1912
hello #mandai

thanks for reply me.
but seems now with the piece while true
my form keeps turning on and off :(

now i can't do anything because its go crazy
any idea?

thanks
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
benji_19994
VIP - Donator
VIP - Donator
Posts: 156
Joined: Mon Apr 16, 2012 3:13 pm

Re: Threading?
benji_19994
Watch this http://www.youtube.com/watch?feature=pl ... K5D4Y2fnl4

This should explain and help you with threading =D
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Threading?
Dummy1912
yea thanks #benji_19994
everything they said i have showed here already :p
so this don't helped me much :)
thanks anyway ;)
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Threading?
Dummy1912
hello,

seems i got it working but how to fix it when you scroll up or down in a panel
i even set the thread to 1000
it freeze a sec :(
any idea how to make go smooth?
thanks
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

Re: Threading?
noypikami
its very well explained here.. this Link could be a help to you..
http://www.vbforums.com/showthread.php? ... -in-VB.Net
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Threading?
Dummy1912
hello #noypikami,

thanks :)
but i solved the thread like i said earlier :)
but still got a problem with scrolling :)
any idea?
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Threading?
Dummy1912
grrrrrrrr
drives me nuts
now the thread runs but if you wait a while before adding a new message
the thread has stops!!!!
how is this even possible when you use a while me.visible?????

seems we got this error in the thread ?
Image

any ideas?
Last edited by Dummy1912 on Tue Mar 12, 2013 10:17 am, edited 1 time in total.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

Re: Threading?
noypikami
may be the problem is with the (while) or loop, coz the app cannot process
the thread when its still busy or in use.

try something like this............

Private Sub check0 (ByVal x As Boolean)
If x=true Then
' do something here
Else
'... do something here
End If
End Sub
17 posts Page 1 of 2
Return to “Coding Help & Support”