Click to See Complete Forum and Search --> : running 2 subs at the same time!?


pepin
September 20th, 2001, 09:00 AM
Hi!
Is it possible to run 2 subs at the same time? One of them displays the position in a label from an extern display unit and the second sub looks at the position and put data in an Excel sheet when the reading is stable.
when I start the sub doing the data acquisition, the label stops being updated.
'*------------------
Private Sub Timer1_Timer()
If MSComm1.PortOpen = True Then
MSComm1.Output = Chr$(stx)
Me.txtPosActuelle.Text = MSComm1.Input
Else
MSComm1.PortOpen = True
MSComm1.Output = Chr$(stx)
Me.txtPosActuelle.Text = MSComm1.Input
End If
End Sub 'interval=100
'*--------------------
Private Function SaisieDonneesForward(position)
Do While Not (Lecture1 < (position + frmParametres.attente) _
And Lecture1 > (position - frmParametres.attente))
MSComm1.InBufferCount = 0
MSComm1.Output = Chr$(stx)
Sleep 150
temp = MSComm1.Input
Lecture1 = FiltreLecture(temp)
Loop
MSComm1.InBufferCount = 0 'première lecture
MSComm1.Output = Chr$(stx)
Sleep Delai
temp = MSComm1.Input
Lecture1 = FiltreLecture(temp)
Sleep (500)
MSComm1.InBufferCount = 0 'deuxième lecture
MSComm1.Output = Chr$(stx)
Sleep Delai
temp = MSComm1.Input
lecture2 = FiltreLecture(temp)
End If
If (lecture2 <> Lecture1) Then 'ça veut dire que ça tourne encore
lecture2 = Rotation()
Worksheets("sheet1").Cells((j + 1), 1).Value = lecture2
Else
Worksheets("sheet1").Cells((j + 1), 1).Value = lecture2
End If
end sub


Thanks!

Valérie Pepin

Boumxyz2
September 20th, 2001, 09:50 AM
In the same or different thread ? If you start a new thread you'll be able to run 2 sub at the same time

Nicolas

pepin
September 20th, 2001, 10:20 AM
qu'est-ce que vous entendez par un même ou différent "thread" ?? Je suis pas trop certaine de comprendre ce qu'un "thread" est.

Valérie Pepin

Boumxyz2
September 20th, 2001, 10:36 AM
Un thread c'est une unite d'execution pour le processeur. Une application peut s'executer sur un ou plusieurs thread...

Exemple..

Si on veut faire executer une chanson pendant que l'on effectue un certain traitement sur un fichier, alors on creerait on nouveau thread permettant de faire jouer le chanson. De l'information sur les thread sont disponibles ici
au
http://www.allapi.net/apilist/apifunction.php?apifunction=CreateThread

ou encore
au
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/hh/winbase/prothred_4084.asp



Nicolas