Ignore:
Timestamp:
Dec 14, 2001, 11:41:33 PM (24 years ago)
Author:
umoeller
Message:

Lots of changes for icons and refresh.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/threads.c

    r116 r123  
    4040    // as unsigned char
    4141
     42#define INCL_WINMESSAGEMGR
    4243#define INCL_DOSPROCESS
    4344#define INCL_DOSSEMAPHORES
     
    130131    if (pti)
    131132    {
     133        HEV hevExitComplete;
     134
    132135        if (pti->flFlags & THRF_WAIT)
    133136            // "Wait" flag set: thrCreate is then
     
    168171        }
    169172
     173        // copy event sem before freeing pti
     174        hevExitComplete = pti->hevExitComplete;
     175
    170176        // set exit flags
    171177        // V0.9.7 (2000-12-20) [umoeller]
    172         pti->fExitComplete = TRUE;
    173178        pti->tid = NULLHANDLE;
    174179
     
    180185        if (pti->flFlags & THRF_TRANSIENT)
    181186            free(pti);
     187
     188        if (hevExitComplete)
     189            // caller wants notification:
     190            DosPostEventSem(hevExitComplete);
     191                    // V0.9.16 (2001-12-08) [umoeller]
    182192    }
    183193
     
    394404 *@@added V0.9.5 (2000-08-26) [umoeller]
    395405 *@@changed V0.9.9 (2001-03-07) [umoeller]: added pcszThreadName
     406 *@@changed V0.9.16 (2001-12-08) [umoeller]: fixed hang with thrWait
    396407 */
    397408
     
    417428    {
    418429        THREADINFO  ti = {0};
     430        volatile unsigned long tidRunning = 0;
    419431        thrCreate(&ti,
    420432                  pfn,
    421                   NULL,
     433                  &tidRunning,
    422434                  pcszThreadName,
    423435                  THRF_PMMSGQUEUE,
    424436                  ulData);
    425437        ti.hwndNotify = hwndNotify;
     438        // create event sem to wait on V0.9.16 (2001-12-08) [umoeller]
     439        DosCreateEventSem(NULL,
     440                          &ti.hevExitComplete,
     441                          0,
     442                          FALSE);       // not posted
    426443
    427444        while (WinGetMsg(hab,
     
    445462        // otherwise THREADINFO is deleted from the stack
    446463        // before the thread exits... will crash!
    447         thrWait(&ti);
     464        // thrWait(&ti);
     465        // now using event sem V0.9.16 (2001-12-08) [umoeller]
     466        WinWaitEventSem(ti.hevExitComplete, 5000);
     467        DosCloseEventSem(ti.hevExitComplete);
    448468
    449469        WinDestroyWindow(hwndNotify);
     
    481501        PLISTNODE pNode;
    482502        *pcThreads = lstCountItems(&G_llThreadInfos);
    483         _Pmpf((__FUNCTION__ ": got %d threads", *pcThreads));
    484503        pArray = (PTHREADINFO)malloc(*pcThreads * sizeof(THREADINFO));
    485504        pThis = pArray;
     
    561580 *      the thread will actually terminate.
    562581 *
     582 *      Update V0.9.16: Do not use this with PM theads at
     583 *      all. DosWaitThread can hang the system then.
     584 *
    563585 *      Returns FALSE if the thread wasn't running or TRUE
    564586 *      if it was and has terminated.
     
    631653{
    632654    if (pti)
    633         if (!(pti->fExitComplete))
    634             return (pti->tid);
     655        return (pti->tid);
    635656
    636657    return (NULLHANDLE);
Note: See TracChangeset for help on using the changeset viewer.