By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,017 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

MultiThread: how can I do two or more procedures

P: 3
MultiThread: how can I do two or more procedures?

Expand|Select|Wrap|Line Numbers
  1. Dim I1 As Integer
  2.     Dim I2 As Integer
  3.  
  4.     Dim THREAD1 As System.Threading.Thread
  5.     Dim THREAD2 As System.Threading.Thread
  6.  
  7.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8.         Control.CheckForIllegalCrossThreadCalls = False
  9.     End Sub
  10.  
  11.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  12.         THREAD1 = New System.Threading.Thread(AddressOf COUNTUP1)
  13.         THREAD1.Start()
  14.     End Sub
  15.  
  16.     Private Sub COUNTUP1()
  17.         Do Until I1 = 1000
  18.             I1 = I1 + 1
  19.             Label1.Text = I1
  20.             Me.Refresh()
  21.         Loop
  22.  
  23.         I1 = 0
  24.     End Sub
  25.  
  26.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  27.         THREAD2 = New System.Threading.Thread(AddressOf COUNTUP2)
  28.         THREAD2.Start()
  29.     End Sub
  30.  
  31.     Private Sub COUNTUP2()
  32.         Do Until I2 = 1000
  33.             I2 = I2 + 1
  34.             Label2.Text = I2
  35.             Me.Refresh()
  36.         Loop
  37.  
  38.         I2 = 0
  39.     End Sub
  40.  
  41.     Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  42.         THREAD1.Abort()
  43.         THREAD2.Abort()
  44.     End Sub
Feb 7 '14 #1
Share this Question
Share on Google+
1 Reply


Frinavale
Expert Mod 5K+
P: 9,731
Create more than one thread?
I'm not clear on what your question is.
Feb 12 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.