Author | Message | Time |
---|---|---|
TriCk | Hey, i need the connection sequence for Extra High Latency... to connect to battle.net. - VB6 | September 13, 2003, 11:01 AM |
Camel | SEND 0x50 RECV 0x25 wait a long time SEND 0x25 | September 13, 2003, 9:52 PM |
hismajesty | [quote author=Camel link=board=17;threadid=2683;start=0#msg21157 date=1063489979] wait a long time [/quote] lol...usually everything is so technical sounding, now it's plain-english...this will take some getting used to. | September 13, 2003, 10:03 PM |
TriCk | Hahaha... Ummm should i use Kernel32's Sleep for the "Long Wait" | September 13, 2003, 11:01 PM |
eRRoR | Just use this to wait when you receive 0x25. [code]Sub Pause(ByVal fSeconds As Single, Optional ByVal AllowEvents As Boolean = True) Dim fTimer As Single If AllowEvents Then fTimer = Timer Do While Timer - fTimer < fSeconds Sleep 100 DoEvents If Timer < fTimer Then fTimer = fTimer - 86400 End If Loop Else Sleep fSeconds * 1000 End If End Sub[/code] | September 14, 2003, 5:35 AM |
iago | It would be better to create a null event, and use WaitForSingleObject(DWORD time);. That way the process will enter a kernel wait mode and wont' take up any cpu cycles till the time runs out. Is that more technical, the way you wanted it? :P | September 14, 2003, 1:35 PM |
hismajesty | [quote author=iago link=board=17;threadid=2683;start=0#msg21216 date=1063546545] Is that more technical, the way you wanted it? :P [/quote] No. ;D | September 14, 2003, 1:40 PM |
Skywing | [quote author=iago link=board=17;threadid=2683;start=0#msg21216 date=1063546545] It would be better to create a null event, and use WaitForSingleObject(DWORD time);. That way the process will enter a kernel wait mode and wont' take up any cpu cycles till the time runs out. Is that more technical, the way you wanted it? :P [/quote] It would be best to use MsgWaitForMultipleObjects with a zero object count (yes, this works). Then, use DoEvents when woken for a message-queue related reason. Remember to adjust the wait time each re-wait. | September 14, 2003, 4:37 PM |
iago | [quote author=Skywing link=board=17;threadid=2683;start=0#msg21234 date=1063557471] [quote author=iago link=board=17;threadid=2683;start=0#msg21216 date=1063546545] It would be better to create a null event, and use WaitForSingleObject(DWORD time);. That way the process will enter a kernel wait mode and wont' take up any cpu cycles till the time runs out. Is that more technical, the way you wanted it? :P [/quote] It would be best to use MsgWaitForMultipleObjects with a zero object count (yes, this works). Then, use DoEvents when woken for a message-queue related reason. Remember to adjust the wait time each re-wait. [/quote] Ah, I didn't know you could do that! And I assumed he was using multiple threads, so he wouldn't require a doevents since the message-queue would still be processing :) | September 14, 2003, 11:17 PM |
St0rm.iD | ...or you could just use sleep... | September 15, 2003, 12:48 AM |
Skywing | [quote author=St0rm.iD link=board=17;threadid=2683;start=0#msg21282 date=1063586892] ...or you could just use sleep... [/quote] This is a Bad Idea if you have a GUI because to the user the program will appear to have completely stopped responding. They may give up and try to end-task it as a result due to the window not being moveable or sizeable and not painting itself. | September 15, 2003, 2:15 AM |
Adron | [quote author=Skywing link=board=17;threadid=2683;start=0#msg21292 date=1063592146] [quote author=St0rm.iD link=board=17;threadid=2683;start=0#msg21282 date=1063586892] ...or you could just use sleep... [/quote] This is a Bad Idea if you have a GUI because to the user the program will appear to have completely stopped responding. They may give up and try to end-task it as a result due to the window not being moveable or sizeable and not painting itself. [/quote] They wouldn't be able to move it very far while sleeping one second anyway. | September 15, 2003, 6:28 PM |
Camel | Using sleep and doevents has been discussed before: here. | September 15, 2003, 7:40 PM |
Skywing | [quote author=Camel link=board=17;threadid=2683;start=0#msg21334 date=1063654856] Using sleep and doevents has been discussed before: here. [/quote] It might be worth noting that there are a fair amount of inaccurate statements there. DoEvents doesn't have all that much in common with Sleep - the documentation says that it only "processes any Windows messages currently in the message queue". This implies that there is no wait involved, and thus no giving up the thread timeslice early for a different thread. A loop with only DoEvents should cause the program to use a fair amount of CPU because it won't relinquish its timeslice early. Sleep, on the other hand, actually blocks the thread in such a way that the thread scheduler simply does not consider it as a candidate for running until the wait interval has expired. Even if your thread were the only thread in the system (which is impossible, because there are a number of kernel mode threads required for the system to run), the kernel idle loop should be getting processor time (and not your thread) while execution is being blocked. | September 15, 2003, 8:27 PM |
Adron | #define DoEvents while(GetMessage(&msg)) DispatchMessage(&msg); Well, add something to stop it from sitting there forever... | September 15, 2003, 9:45 PM |
Lenny | [quote author=eRRoR link=board=17;threadid=2683;start=0#msg21204 date=1063517737] Just use this to wait when you receive 0x25. [code]Sub Pause(ByVal fSeconds As Single, Optional ByVal AllowEvents As Boolean = True) Dim fTimer As Single If AllowEvents Then fTimer = Timer Do While Timer - fTimer < fSeconds Sleep 100 DoEvents If Timer < fTimer Then fTimer = fTimer - 86400 End If Loop Else Sleep fSeconds * 1000 End If End Sub[/code] [/quote] This code gives an extra 300ms delay when used as opposed to Sleep. can some1 this code to me? | September 21, 2003, 8:57 AM |
Lenny | Nvm just found out that Timer was internal clock seconds from midnight...... | September 21, 2003, 9:18 AM |