Bonjour à tous!!
J'ai un gros problème qui me bloque définitivement dans mon programme.
J'utilise deux threads pour envoyer respectivement une fonction d'écriture et une fonction de lecture. Il faut cependant absolument que ces deux threads s'éxecutent en parallèle.
Alors j'ai fait ca, c'est-à-dire deux threads:
Est ce que je pars sur le bon chemin ?? Cependant ces deux threads la ne se font toujours pas en parallèle...
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 bool Maintenance::InitThread() { m_pThread = AfxBeginThread(ThreadFunc, this); if(!m_pThread) { // Impossible de créer le thread ! return false; } return true; } bool Maintenance::InitThread2() { m_pThread2 = AfxBeginThread(ThreadFunc2, this); if(!m_pThread2) { // Impossible de créer le thread ! return false; } return true; } UINT Maintenance::ThreadFunc(LPVOID pvParam) { Maintenance *pThis=reinterpret_cast< Maintenance *>( pvParam) ; // Thread code while(1) { Card.ReadnExec(); } return 0 ; } UINT Maintenance::ThreadFunc2(LPVOID pvParam) { Maintenance *pThis=reinterpret_cast< Maintenance *>( pvParam) ; // Thread code while(1) { Card.enableCard(); } return 0 ; } BOOL Maintenance::OnInitDialog() { CDialog::OnInitDialog(); CCom::ClosePortCom(); CCom::InitPortCom(); i=0; //initialisation of the thread InitThread(); if(InitThread()!=TRUE) AfxMessageBox("erreur à l'initialisation du thread"); //initialisation of the thread InitThread2(); if(InitThread2()!=TRUE) AfxMessageBox("erreur à l'initialisation du thread"); return(TRUE); }
Merci d'avance






Répondre avec citation
Partager