ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
MFC and aw_wait()? (Sdk)
MFC and aw_wait()? // Sdkbyte meFeb 15, 1999, 10:20pm
Ok I've been working on a program, and when ever I call aw_wait(); the
program locks up for the amount of time I entered in the aw_wait, anyone know how I might fix this? rjinswandFeb 15, 1999, 11:40pm
This is a multi-part message in MIME format.
------=_NextPart_000_0081_01BE590A.55E57A40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Call aw_wait() for 0 ms. Rjinswand [View Quote] ------=_NextPart_000_0081_01BE590A.55E57A40 Content-Type: text/x-vcard; name="Rjinswand.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Rjinswand.vcf" BEGIN:VCARD VERSION:2.1 N:;Rjinswand FN:Rjinswand ORG:Rjeneration URL: URL:http://table.jps.net/~rjins/rjeneration EMAIL;PREF;INTERNET:bcnu at psicorps.com REV:19990216T014053Z END:VCARD ------=_NextPart_000_0081_01BE590A.55E57A40-- byte meFeb 15, 1999, 11:55pm
What do you mean?
I have to call it for 10000 ms... [View Quote] > Call aw_wait() for 0 ms. > > Rjinswand > [View Quote] edward sumerfieldFeb 16, 1999, 1:42pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html> Why do you have to do that? A 10 second wait is a long time. All this call does is wait for events from the world you are in. A call of 0 ms will check for events once and then return. A call for 10 seconds will sit and wait for events to arrive. <p>There is almost no difference between calling aw_wait(0) every second for 10 seconds or calling aw_wait(10000). <p>Personally I use 1 second polls and make changes to avatars at that interval to ensure that each change will get propagated to other browsers. Of coarse I am not using MFC and have no other blocking calls in my program. [View Quote] byte meFeb 16, 1999, 4:06pm
I need the 10 second wait because it changes an object ever 10
seconds... [View Quote] > Why do you have to do that? A 10 second wait is a long time. All this > call does is wait for events from the world you are in. A call of 0 ms > will check for events once and then return. A call for 10 seconds will > sit and wait for events to arrive. > > There is almost no difference between calling aw_wait(0) every second > for 10 seconds or calling aw_wait(10000). > > Personally I use 1 second polls and make changes to avatars at that > interval to ensure that each change will get propagated to other > browsers. Of coarse I am not using MFC and have no other blocking > calls in my program. > [View Quote] edward sumerfieldFeb 16, 1999, 5:11pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html> Then use a 1 second wait and add a counter that counts to 10. When it reaches 10 change the object. <p> int count = 10; <br> while (aw_wait(1000)) { <p> if (count == 0) { <p> change object <br> count = 10; <br> } <br> count--; <br> } <p>If that is too long then make it a 1 milli second wait and count to 10000. [View Quote] byte meFeb 16, 1999, 5:27pm
Yes but aw_wait(); locks up a MFC program... so I have to use SetTimer()
and in the WM_TIMER I have aw_wait(0); [View Quote] > Then use a 1 second wait and add a counter that counts to 10. When it > reaches 10 change the object. > > int count = 10; > while (aw_wait(1000)) { > > if (count == 0) { > > change object > count = 10; > } > count--; > } > > If that is too long then make it a 1 milli second wait and count to > 10000. > [View Quote] edward sumerfieldFeb 16, 1999, 5:59pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html> So, you can put your counter into the function that is called when the timer pops. Make the timer pop every second, call aw_wait(0) every second but only change your object, from that same function, when the counter reaches zero. <p>Well, as I am not an MFC guru I should leave this one to Walter, sorry if I have wasted your time. [View Quote] walter knupeFeb 16, 1999, 7:16pm
This is a multi-part message in MIME format.
------=_NextPart_000_004B_01BE59FA.0EE46DE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable The only thing i can add is that another option is to set up a second = timer which triggers every 10 seconds and performs the object changes. an MFC application which responds to timers usually consists of a = one-time call to setup the timer, so in this case say #define AWPOLLTIMER 42 #define OBJECTTIMER 43 SetTimer(AWPOLLTIMER, 1000, NULL); // NULL since we don't want a direct = timer function=20 SetTimer(OBJECTTIMER, 10000, NULL);=20 and then, you use the development environment to add a function to your = window class which is called on timer timeouts: void CSomeDlg::OnTimer(int TimerID) // which would be implemented in this case like { switch (TimerID) { case AWPOLLTIMER: aw_wait(0); break; case OBJECTTIMER: DoObjectChanges(); break; default: CDialog::OnTimer(); // assuming CDialog is our base = class here } } But your solution below is perfectly valid :) Walter aka Faber Edward Sumerfield schrieb in Nachricht = <36C9CE39.7FFCB4A at poboxes.com>... So, you can put your counter into the function that is called when = the timer pops. Make the timer pop every second, call aw_wait(0) every = second but only change your object, from that same function, when the = counter reaches zero.=20 Well, as I am not an MFC guru I should leave this one to Walter, = sorry if I have wasted your time.=20 [View Quote] Yes but aw_wait(); locks up a MFC program... so I have to use = SetTimer()=20 and in the WM_TIMER I have aw_wait(0);=20 [View Quote] > Then use a 1 second wait and add a counter that counts to 10. = When it=20 > reaches 10 change the object.=20 >=20 > int count =3D 10;=20 > while (aw_wait(1000)) {=20 >=20 > if (count =3D=3D 0) {=20 >=20 > change object=20 > count =3D 10;=20 > }=20 > count--;=20 > }=20 >=20 > If that is too long then make it a 1 milli second wait and = count to=20 > 10000.=20 >=20 [View Quote] the=20 > ------=_NextPart_000_004B_01BE59FA.0EE46DE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN"> <HTML> <HEAD> <META content=3Dtext/html;charset=3Diso-8859-1 = http-equiv=3DContent-Type><!doctype html public "-//w3c//dtd html 4.0 = transitional//en"> <META content=3D'"MSHTML 4.72.3511.1300"' name=3DGENERATOR> </HEAD> <BODY bgColor=3D#b8b8b8> <DIV><FONT face=3DArial size=3D2>The only thing i can add is that = another option is=20 to set up a second timer which triggers every 10 seconds and performs = the object=20 changes.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>an MFC application which responds to = timers usually=20 consists of a one-time call to setup the timer, so in this case = say</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT color=3D#000000 face=3DArial size=3D2>#define AWPOLLTIMER = 42</FONT></DIV> <DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT><FONT = face=3DArial=20 size=3D2>#define OBJECTTIMER 43</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>SetTimer(AWPOLLTIMER, 1000, = NULL); // NULL=20 since we don't want a direct timer function </FONT></DIV> <DIV><FONT face=3DArial size=3D2>SetTimer(OBJECTTIMER, 10000, NULL); = </FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>and then, you use the development = environment to=20 add a function to your window class which is called on timer=20 timeouts:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>void CSomeDlg::OnTimer(int = TimerID)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>// which would be implemented in this = case=20 like</FONT></DIV> <DIV><FONT face=3DArial size=3D2>{</FONT></DIV> <DIV><FONT face=3DArial size=3D2> switch = (TimerID)</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT><FONT color=3D#000000 = face=3DArial=20 size=3D2> {</FONT></DIV> <DIV><FONT color=3D#000000 face=3DArial=20 size=3D2> case AWPOLLTIMER: = aw_wait(0);=20 break;</FONT></DIV> <DIV><FONT color=3D#000000 face=3DArial=20 size=3D2> case OBJECTTIMER:=20 DoObjectChanges(); break;</FONT></DIV> <DIV><FONT color=3D#000000 face=3DArial=20 size=3D2> default:=20 CDialog::OnTimer(); // assuming CDialog is our base class=20 here</FONT></DIV> <DIV><FONT color=3D#000000 face=3DArial size=3D2> = }</FONT></DIV> <DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT><FONT = face=3DArial=20 size=3D2>}</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>But your solution below is perfectly = valid=20 :)</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Walter aka Faber</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <BLOCKQUOTE=20 style=3D"BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: = 5px"> <DIV>Edward Sumerfield<ESUMERFD at POBOXES.COM> schrieb in Nachricht = <<A=20 = href=3D"mailto:36C9CE39.7FFCB4A at poboxes.com">36C9CE39.7FFCB4A at poboxes.com= </A>>...</DIV>So,=20 you can put your counter into the function that is called when the = timer=20 pops. Make the timer pop every second, call aw_wait(0) every second = but only=20 change your object, from that same function, when the counter = reaches zero.=20 <P>Well, as I am not an MFC guru I should leave this one to Walter, = sorry if=20 I have wasted your time.=20 [View Quote] ------=_NextPart_000_004B_01BE59FA.0EE46DE0-- |