Bonjour,

j'ai parcouru le forum, google et MSDN mais je ne trouve pas/ ne comprend pas, la gestion de plusieurs threads.

notamment l'utilsation et l'exploitation des valeurs retournées par WaitForMultipleObjects.

dans mon prog exemple j'ai ce 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
 
DWORD WINAPI NotificationProc( LPVOID lpParameter )
{
    HRESULT hr;
    HWND    hDlg = (HWND) lpParameter;
    MSG     msg;
    DWORD   dwResult;
    BOOL    bDone = FALSE;
    BOOL    bLooped;
 
    while( !bDone ) 
    { 
        dwResult = MsgWaitForMultipleObjects( 1, &g_hNotificationEvent[0], 
                                              FALSE, INFINITE, QS_ALLEVENTS );
        switch( dwResult )
        {
            case WAIT_OBJECT_0 + 0:
                // g_hNotificationEvent is signaled
 
                // This means that DirectSound just finished playing 
                // a piece of the buffer, so we need to fill the circular 
                // buffer with new sound from the wav file
                bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
                if( FAILED( hr = g_pStreamingSound[0]->HandleWaveStreamNotification( bLooped ) ) )
                {
                    DXTRACE_ERR_MSGBOX( TEXT("HandleWaveStreamNotification"), hr );
                    MessageBox( hDlg, "Error handling DirectSound notifications."
                               "Sample will now exit.", "DirectSound Sample", 
                               MB_OK | MB_ICONERROR );
                    bDone = TRUE;
                }
 
                break;
 
            case WAIT_OBJECT_0 + 1:
                // Messages are available
                while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) 
                { 
                    if( msg.message == WM_QUIT )
                        bDone = TRUE;
                }
                break;
        }
    }
 
    return 0;
}
J'ai cru comprendre que pour gérer mes 3 threads dans cette même fonction je devais renplacer l'appel de waitformultipleobject par :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
dwResult = MsgWaitForMultipleObjects( 3, &g_hNotificationEvent[0], 
                                              FALSE, INFINITE, QS_ALLEVENTS );
g_hNotificationEvent étant le tableau des 3 évenements crées pour les 3 threads.

je comprend bien que l'événement ce produit mais comment savoir quel threads l'a déclenché ? le 1er, le 2nd ou le dernier ?

merci d'avance, ja rame a mort avec les threads