Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!caen!kuhub.cc.ukans.edu!markv From: markv@kuhub.cc.ukans.edu Newsgroups: comp.sys.amiga.programmer Subject: Re: Window Waiting (was ) Message-ID: <1991May24.092943.31027@kuhub.cc.ukans.edu> Date: 24 May 91 14:29:43 GMT References: <1991May24.102345.1@wombat.newcastle.edu.au> Organization: University of Kansas Academic Computing Services Lines: 83 > Currently I am delaying by Delay(60) and then checking the windows message > port for a message, outputting my info, then looping back to the Delay. > ... > So the basic idea is, how can I start a timed event that will pump a signal > to me when it completes, so that I can have the program waiting for a signal > from that timer or from the window message port...hence if the user clicks > on the close gadget, it immediately can respond ? There are two solutions. One, if you only wan't to update the display when your window is active, and if you aren't real picky about precision, try INTUITICKS messsage. I do this to update a clock counter, recheck memory, like this: while(!QuitFlag) { WaitPort(MyWindow->UserPort); while ((MyMsg = GetMsg(MyWindow->UserPort)) != NULL) { switch(MyMsg->Class) { case INTUITICK: if((TickCount++) % 10) == 0) { DoUpdateStuff(); } break; case CLOSEWINDOW: QuitFlag = FALSE; break; /* ... etc ... */ } ReplyMsg(MyMsg); } } Intuiticks arrive roughly 10 per second when your window is active. Also, Intuition only sends one at a time, so you dont get a 2nd Intuitick until you reply the 1st. The catch is they aren't very precise, and dont' get sent if your window isn't active. But they are good for "kicker" events. If you need more precision, or events when you window is inactive, or really *only* want to wake up once per second, then you'll have to use the timer.device and set up 1 second timer requests. Then you can wait on the Bitwise or of the signal bits for the timer reply port and the window's port like this: #define BIT(x) (1L << x) ULONG WakeupMask; #define WindowBit BIT(MyWindow->UserPort->mp_Sigbit) #define TimerBit BIT(TimerReplyPort->mp_Sigbit) WakeupMask = Wait(WindowBit | TimerBit); if (WakeupMask & WindowBit) { /* Do IDCMP stuff */ } if (WakeupMask & TimerBit) { /* Do update stuff */ } This way you will get awakened by the timer IO coming back, meaning your time is expired, or by a window event. You must check the WakeupMask for ALL bits you've used, since it is possible (and likely sooner or later) that you will get awakend by more than just one of the possibilities. > Assembly or C answers.... Hope this helps. I won't get into all the details of the timer device stuff unless you ask. Also, this is off the top of my head at work, so excuse minor errors in names or case. > Thanks, > > Robert Lang. For now, -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark Gooderum Only... \ Good Cheer !!! Academic Computing Services /// \___________________________ University of Kansas /// /| __ _ Bix: mgooderum \\\ /// /__| |\/| | | _ /_\ makes it Bitnet: MARKV@UKANVAX \/\/ / | | | | |__| / \ possible... Internet: markv@kuhub.cc.ukans.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~