Bonjour,


Voila j'excute un thread et j'aimerai pouvoir mettre le résultat du thread dans un textBox. Mais j'ai toujours l'erreur suivante qui apparait:
Opération inter-threads non valide : le contrôle 'txt_bois' a fait l'objet d'un accès à partir d'un thread autre que celui sur lequel il a été créé.
Voilà mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 Dim bois As String
    Dim prod_bois As String
    Dim ress As Boolean = True

    Dim thread_Bois As Thread
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Chargement()
    End Sub

    Public Sub Augmente_ressource()
        While ress
            bois = bois + CInt(prod_bois / 60)
            Me.txt_bois.Text = bois 
           Thread.Sleep(60000)
        End While
    End Sub

    Protected Sub Lancement()
        thread_Bois = New Thread(AddressOf Augmente_ressource)
        bois = Me.txt_bois.Text
        prod_bois = Me.txt_Prod_Bois.Text
        thread_Bois.Start()

    End Sub
L'erreur survient sur la ligne Rouge.

Comment mettre la valeur dans la TextBox.
Merci pour votre aide.