TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Phil Crown
date: 1995-11-13 12:31:04
subject: waiting on a session

I found a way to wait for a session started with DosStartSession to end.
May not be perfect, and may even be dangerous.  Any comments, questions,
criticisms?

  ... this is a thread that starts an external program (Zmodem or HSLink) in
      my case

  rc = DosSuspendThread(pdata->tidReadThread);
  rc = DosStartSession(&StartData, &SessID, &pid);
  WaitForSession(&pdata->tidHsl, SessID);
  rc = DosResumeThread(pdata->tidReadThread);
  WinTerminate(hab);
  _endthread();
}

// --------------------------------------------------------------------

VOID    WaitForSession(PTID ptid, ULONG SessID)
{
  STATUSDATA  sd;
  INT         i = 0;

  sd.Length = sizeof(STATUSDATA);
  sd.SelectInd  = SET_SESSION_UNCHANGED;
  sd.BondInd    = SET_SESSION_UNCHANGED;

  i = 0;

  while(*ptid == 0 && i++ < 10)     // Allow time for the thread (above)
    DosSleep(1000);                 // to get started, should be a semaphore
                                    // but this was quick and dirty

  while(DosSetSession(SessID, &sd) == 0)  // This waits for the session to
    DosSleep(1000);                       // end.  DosSetSession returns !0
                                          // when the session no longer
                                          // exists.
                                          // The only thing that bothers
                                          // me, is that too many calls to
                                          // DosSetSession may cause problems
                                          // since this last for the
                                          // duration of the transfer
  *ptid = 0;
}

phil.crown{at}bluecafe.com


--- Blue Wave/Max v2.22a
* Origin: * MacSavvy * Dallas * Mac * OS/2 * (214)250-4479 * (1:124/1208)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 517 628 713/888 800/1 7877/2809
@PATH: 124/1208 1 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.