none
Inter process communication RRS feed

  • Question

  • Hi, 
    i have a task to record to videos simultaneously in avi format. therefore i am using two processes to record these videos that are implemented using direct show. These two processes are started in the as mentioned below:
    STARTUPINFO siVideo1;
    PROCESS_INFORMATION piVideo1;
    ZeroMemory( &siVideo1, sizeof(siVideo1));
    siVideo1.cb = sizeof(STARTUPINFO);
    ZeroMemory( &piVideo1, sizeof(piVideo1));
    if (!CreateProcess(NULL,"D:\\VC_Proj\\Threading\\Process1\\Debug\\Process1.exe" ,NULL,NULL,FALSE,0,NULL, NULL,&siVideo1, &piVideo1 ))
    {
    printf("\nChannel-1 REC FAIL");
    }/**/
    STARTUPINFO siVideo2;
    PROCESS_INFORMATION piVideo2;
    ZeroMemory( &siVideo2, sizeof(siVideo2));
    siVideo2.cb = sizeof(siVideo2);
    ZeroMemory( &piVideo2, sizeof(piVideo2));
    if (!CreateProcess( NULL, "D:\\VC_Proj\\Threading\\Process2\\Debug\\Process2.exe", NULL,NULL,FALSE,0,NULL, NULL,&siVideo2, &piVideo2 ))
    {
    printf("\nChannel-2 REC FAIL");
    }/**/
    Now these two processes are working fine until an external event from serial port comes to close the avi files and stops recording. i have one serial port and i have to sample it in main program and send instruction to my processes to close their respective files and stop recording, but i am not finding any way to do communication with my processes and call the respective functions in the processes to stop graph and close the files. just blank on how to use inter process communication for this type of application and which type of IPC should i use. can u please guide me in an easy way with example if possible.
    regards 
    Monday, January 9, 2012 6:23 AM

Answers

  • Maybe you can use events. Your main process will create a named event using CreateEvent before starting processes. The processes will open the same event using OpenEvent. When the processes should stop, main program calls SetEvent. The processes will check the event using WaitForMulipleObjects or WaitForSingleObject. The main program will use WaitForMulipleObjects with thread handles from PROCESS_INFORMATION in order to wait for termination of processes.

     

    • Proposed as answer by SOU (Sourabh Arvikar) Monday, January 9, 2012 7:37 AM
    • Marked as answer by Rob Pan Wednesday, January 18, 2012 6:09 AM
    Monday, January 9, 2012 6:35 AM
  • All the processes can call RegisterWindowMessage with same name as parameter.

    The controlling process can send this message using SendMessage or PostMessage.

    When Process1/Process2 receives this message, it can do the necessary steps to stop recording.

     

    You could also do this using a named event.

    All processes can use CreateEvent with the same name as the lpName parameter.

    Process1/Process2 can then wait on this event using WaitForSingleObject.

    The controlling processing can call SetEvent when it wants to signal the event.

     


    «_Superman_»
    Microsoft MVP (Visual C++)

    Polymorphism in C
    • Marked as answer by Rob Pan Wednesday, January 18, 2012 6:09 AM
    Monday, January 9, 2012 6:43 AM

All replies

  • Maybe you can use events. Your main process will create a named event using CreateEvent before starting processes. The processes will open the same event using OpenEvent. When the processes should stop, main program calls SetEvent. The processes will check the event using WaitForMulipleObjects or WaitForSingleObject. The main program will use WaitForMulipleObjects with thread handles from PROCESS_INFORMATION in order to wait for termination of processes.

     

    • Proposed as answer by SOU (Sourabh Arvikar) Monday, January 9, 2012 7:37 AM
    • Marked as answer by Rob Pan Wednesday, January 18, 2012 6:09 AM
    Monday, January 9, 2012 6:35 AM
  • All the processes can call RegisterWindowMessage with same name as parameter.

    The controlling process can send this message using SendMessage or PostMessage.

    When Process1/Process2 receives this message, it can do the necessary steps to stop recording.

     

    You could also do this using a named event.

    All processes can use CreateEvent with the same name as the lpName parameter.

    Process1/Process2 can then wait on this event using WaitForSingleObject.

    The controlling processing can call SetEvent when it wants to signal the event.

     


    «_Superman_»
    Microsoft MVP (Visual C++)

    Polymorphism in C
    • Marked as answer by Rob Pan Wednesday, January 18, 2012 6:09 AM
    Monday, January 9, 2012 6:43 AM