Okay I have the folowing code.
VB Code:
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed mescounter = mescounter + 1 Me.txtmescount.Text = 60 - mescounter If mescounter = 60 Then processall() ' process all waiting message and e-mails mescounter = 0 End If If doweb Then If curday <> 1 And curday <> 7 Then If curhour > 7 And curhour < 18 Then webcounter = webcounter + 1 Me.txtwebcount.Text = 60 - webcounter If webcounter = 60 Then processweb() ' exports call data to website webcounter = 0 End If Else webcounter = webcounter + 1 If webcounter = 60 Then webcounter = 0 End If Me.txtwebcount.Text = "Paused OOH" End If Else webcounter = webcounter + 1 If webcounter = 60 Then webcounter = 0 End If Me.txtwebcount.Text = "Paused W/E" End If End If End Sub Private Sub processweb() If processingweb = False Then processingweb = True Me.Pbweb.Value = 10 Me.txtwebcall.Text = CStr(CLng(Me.txtwebcall.Text) + upwebsite.getupcalldata()) Me.Pbweb.Value = 20 Me.txtwebcomp.Text = CStr(CLng(Me.txtwebcomp.Text) + upwebsite.getupcompdata()) Me.Pbweb.Value = 50 Me.txtwebemp.Text = CStr(CLng(Me.txtwebemp.Text) + upwebsite.getupempdata()) Me.Pbweb.Value = 70 Me.txtwebcon.Text = CStr(CLng(Me.txtwebcon.Text) + upwebsite.getupcondata()) Me.Pbweb.Value = 90 Me.txtremwebemp.Text = CStr(CLng(Me.txtremwebemp.Text) + upwebsite.getwebchanges()) Me.Pbweb.Value = 100 Me.Pbweb.Value = 0 processingweb = False End If End Sub
Now my problem is that the processweb() sub can sometimes freeze for minutes on end if our Internet conection is down or running very slowly, currently when this happens the other sub processall() doesn't get run. I'm assuming the whole application is locking up until the processweb() task completes.
To solve this problem would you use threads? and how easy would it be to convert the above to threading, basically I know nothing about threading or even if this is what I need, so perhaps some general pointers would be useful.




Reply With Quote