Nov 10, 2015 06:59 AM
(This post was last modified: Nov 10, 2015 07:13 AM by SIM-2362662.)
So i'm using a thread let's say to count up to 1000. after it gets to 1000 i want it to want it to wait 1s and continue.
I tried with Threading.Thread.Sleep(1000) but this command also make the gui unresponding...
Any better alternative?
I haven't worked with threads very much, but if I had to guess, I'd say you're making the GUI sleep instead of your worker thread.
Code Dim myThread As Sytem.Threading.Thread
myThread.Sleep(1000)
(Nov 10, 2015 07:06 AM)Hawk HF Wrote: I haven't worked with threads very much, but if I had to guess, I'd say you're making the GUI sleep instead of your worker thread.
Code Dim myThread As Sytem.Threading.Thread
myThread.Sleep(1000)
I tried that. GUI is still not responding.
(Nov 10, 2015 07:09 AM)SIM-2362662 Wrote: I tried that. GUI is still not responding.
It should not be since you have two separate threads.
Can you provide some code?
Yeah post some code so we can help.
Yea, we need some code to see what's wrong.
DO NOT DEAL WITH THIS MEMBER
I hope you're not calling Thread.Sleep() from the main thread.
Code 'Dim t As New Thread(AddressOf CountUp)
't.Start()
Private Sub CountUp()
For i As Integer = 0 To 1000
Debug.WriteLine(i)
Next
Thread.Sleep(1000)
End Sub
(Nov 10, 2015 07:16 AM)Hawk HF Wrote: It should not be since you have two separate threads.
Can you provide some code?
I managed to fix it . Apperantly the main ui freezed because i used a set.visibility before sleeep (wtf..)
I removed that line and now it works fine. I still can't understand why that line would create such a error .. Anyway thank you man.
DO NOT DEAL WITH THIS MEMBER
(Nov 10, 2015 07:54 AM)SIM-2362662 Wrote: I managed to fix it . Apperantly the main ui freezed because i used a set.visibility before sleeep (wtf..)
I removed that line and now it works fine. I still can't understand why that line would create such a error .. Anyway thank you man.
why would you do that?
there is no logic there.
Nov 10, 2015 10:26 AM
(This post was last modified: Nov 10, 2015 10:27 AM by +Haze.)
(Nov 10, 2015 07:54 AM)SIM-2362662 Wrote: I managed to fix it . Apperantly the main ui freezed because i used a set.visibility before sleeep (wtf..)
I removed that line and now it works fine. I still can't understand why that line would create such a error .. Anyway thank you man.
Post your code here so we can have a look. It's better for you to understand why a piece of code works than you to leave without the understanding.
Nov 10, 2015 11:48 AM
(This post was last modified: Nov 10, 2015 12:07 PM by IAmNotHere.)
Add a stopwatch, no CPU will usage will harm your computer or your computer fan starts making noise and your gui does respond.
Take care.
|