Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

MultiThreading problem - UI still freezes

$
0
0
I want to use a worker thread to do some long running process. I have tried the code below with no luck. What am I doing wrong?

[Public Delegate Sub firstDelegate
Public Delegate Sub secDelegate

Private Sub btnRecords_Click() Handles btnRecords.Click

Dim Start As New firstDelegate (AddressOf Me.allRecords)
Start.BeginInvoke(Nothing,Nothing)

End Sub

Private Sub sTimer()

'Show counter in the tBox
Do while i >= 0
txtBox1.Text=i
I += 1
Loop

End Sub

Private Sub allRecords()

'Schedule second timer to run and display the timer
Me.Dispatcher.BeginInvoke(DispatcherPriority.Normal, New secDelegate (AddressOf STimer))

'Processing happens here
'Thread.Sleep(20000)

End Sub]

'''''''''''''''''''''''''''''''''''''''''''''''''''''
The process does run but the tBox does not show the counter and UI still remains unresponsive. Can somebody assist me. Thanks a lot

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>