A Multithreading problem come from SendMessage - Programmer

This is a discussion on A Multithreading problem come from SendMessage - Programmer ; Hi, i have done my own video player which support lot's of video format.....throught direct show or own source code.... but i have a small problem with a SendMessage... User can perform 3 actions Play, Pause and Stop..... * Play ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: A Multithreading problem come from SendMessage

  1. A Multithreading problem come from SendMessage

    Hi, i have done my own video player which support lot's of video
    format.....throught direct show or own source code....
    but i have a small problem with a SendMessage...
    User can perform 3 actions Play, Pause and Stop.....
    * Play launch a thread and an SetEvent(E_PAUSE) to release it because thread
    loop begin with a WaitForMultipleObject of E_PAUSE or E_KILL
    * Pause ResetEvent(E_PAUSE)
    * Stop ResetEvent(E_PAUSE) and SetEvent(E_KILL) and wait for Thread
    Terminaison throught a WaitForSingleObject of E_END

    The thread could be describe as :
    do
    {
    WaitForMultipleObject of E_PAUSE or E_KILL
    If E_KILL then Goto END_LABEL end if

    Read Frame
    Display frame and update SlideCtrl Position
    }while ......

    END LABEL :
    SetEvent(E_END)
    ExitThread()

    but when i want Stop the thread dead-lock can occur because SendMessage
    (hide behind SetPos of the Slider Ctrl) wait for return....(blocking
    fonction ....)....so if i wait in the stop function that E_END come and i
    wait in my thread that the dialog treat the SETPOS message, my application
    is locked .....

    An advice will be welcome .....



  2. Re: A Multithreading problem come from SendMessage

    In message , Alexandre Buisson
    writes
    >Hi, i have done my own video player which support lot's of video
    >format.....throught direct show or own source code....
    >but i have a small problem with a SendMessage...


    Use PostMessage. Never use SendMessage in multi-threaded apps when
    wanting to send a message from the non UI-thread.

    PostMessage can't block in the way you describe.

    Stephen
    --
    Stephen Kellett
    Object Media Limited http://www.objmedia.demon.co.uk
    RSI Information: http://www.objmedia.demon.co.uk/rsi.html

+ Reply to Thread