File:  [OS/2 SDKs] / os2sdk / demos / examples / asyncio / asyncio.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:12 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1988, HEAD
Microsoft OS/2 SDK 03-01-1988

/*
 * Example of DosWriteAsync. (DosReadAsync is not demonstrated,
 * but has identical usage).
 *
 * In this example, the program uses DosWriteAsync to write a
 * large block of data to the screen asynchronously, while the
 * main program sits in a loop beeping.
 *
 * Compile as: cl -AL -G2 -Lp async.c
 *
 * Created by Microsoft Corp. 1986
 */

#define INCL_DOSPROCESS
#define INCL_DOSFILEMGR
#define INCL_DOSSEMAPHORES

#include <os2def.h>
#include <bsedos.h>

#define FREQ 440
#define DURATION 500L

char cbuf[10 * 1024];		/* buffer to write from */
long sem;			/* ram semaphore */

main()
{
	int i;
	unsigned rc;		/* return code */
	unsigned bytecount;	/* bytes written */

	for(i = 0; i < sizeof(cbuf); i++)	/* init buffer */
		cbuf[i] = 'x';

	sem = 0;
	DosSemSet((HSEM)&sem);	       /* set semaphore */
	DosWriteAsync(1,&sem,&rc,cbuf,sizeof(cbuf),&bytecount);

	for(i = 0; i < 10; i++) {
		DosBeep(FREQ, DURATION);
		DosSleep(DURATION);
	}

	DosSemWait((HSEM)&sem, -1L);
	printf("return code = %d, bytes written = %d\n", rc, bytecount);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.