|
|
1.1 root 1: /* 1.1.1.2 ! root 2: * Example of DosWriteAsync. (DosReadAsync is not demonstrated, 1.1 root 3: * but has identical usage). 4: * 1.1.1.2 ! root 5: * In this example, the program uses DosWriteAsync to write a 1.1 root 6: * large block of data to the screen asynchronously, while the 7: * main program sits in a loop beeping. 8: * 9: * Compile as: cl -AL -G2 -Lp async.c 10: * 1.1.1.2 ! root 11: * Created by Microsoft Corp. 1986 1.1 root 12: */ 13: 1.1.1.2 ! root 14: #define INCL_DOSPROCESS ! 15: #define INCL_DOSFILEMGR ! 16: #define INCL_DOSSEMAPHORES ! 17: ! 18: #include <os2def.h> ! 19: #include <bsedos.h> 1.1 root 20: 21: #define FREQ 440 22: #define DURATION 500L 23: 24: char cbuf[10 * 1024]; /* buffer to write from */ 25: long sem; /* ram semaphore */ 26: 27: main() 28: { 29: int i; 30: unsigned rc; /* return code */ 31: unsigned bytecount; /* bytes written */ 32: 33: for(i = 0; i < sizeof(cbuf); i++) /* init buffer */ 34: cbuf[i] = 'x'; 35: 36: sem = 0; 1.1.1.2 ! root 37: DosSemSet((HSEM)&sem); /* set semaphore */ ! 38: DosWriteAsync(1,&sem,&rc,cbuf,sizeof(cbuf),&bytecount); 1.1 root 39: 40: for(i = 0; i < 10; i++) { 1.1.1.2 ! root 41: DosBeep(FREQ, DURATION); ! 42: DosSleep(DURATION); 1.1 root 43: } 44: 1.1.1.2 ! root 45: DosSemWait((HSEM)&sem, -1L); 1.1 root 46: printf("return code = %d, bytes written = %d\n", rc, bytecount); 47: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.