CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2001
    Location
    Longueuil, Canada
    Posts
    6

    running 2 subs at the same time!?

    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

  2. #2
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: running 2 subs at the same time!?

    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

    Nicolas Bohemier

  3. #3
    Join Date
    Aug 2001
    Location
    Longueuil, Canada
    Posts
    6

    Re: running 2 subs at the same time!?

    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

  4. #4
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: running 2 subs at the same time!?

    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/apifun...n=CreateThread

    ou encore
    au
    http://msdn.microsoft.com/library/de...thred_4084.asp



    Nicolas



    Nicolas Bohemier

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured