frmHub.DoEventsForMe
Moderator: Moderators
-
- Posts: 80
- Joined: 2003-03-21 10:17
- Location: Concepcion, Chile.
frmHub.DoEventsForMe
what does it the instruction "frmHub.DoEventsForMe"?
I have this instructions in some scripts, in some custom commands, but in another ones, it doesn't appear. When does it use?
I have this instructions in some scripts, in some custom commands, but in another ones, it doesn't appear. When does it use?
In Theory, there is no difference between Theory and Practice. In Practice, there is.
Re: frmHub.DoEventsForMe
it makes sure the command is executedKenneth-Chile wrote:what does the instruction "frmHub.DoEventsForMe" [do]?
for instance if you send a message to a user and then disconnect him,
without the DoEvents after the message (before the disconnect), you cannot be sure that the message is sent before the user is disconnected.
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
-
- Forum Moderator
- Posts: 587
- Joined: 2003-05-07 02:38
- Location: Sweden, Linkoping
well Sedulus didnt post before i clic on reply...joakim_tosteberg wrote:Two different explanation, wonder which is the correct one?
Or is both correct?
the two explaination are the same, but view on a different side.
your waitaing for something here don't you ?you cannot be sure that the message is sent before the user is disconnected.
if it's the same as VB.net DoEvent
i had to stop the searchkick of gadget cos my users were kicked with no reason sent
finally i had to delete the curUser.Kick() and kick them manually
dont know the reason
snooze, you are doing a good job in your forum, congratulations
Code: Select all
Else
curUser.PrivateMessage cStr(Kicker),Kicker+" is kicking "+CurUser.sName+" because: "+Reason+" ("+sFileName+")"
colUsers.SendChatToAll cStr(Kicker),Kicker+" is kicking "+CurUser.sName+" because: "+Reason+" ("+sFileName+")"
colUsers.SendChatToAll "Hub-Security","The user "+CurUser.sName+" was kicked by "+Kicker+". IP: "+CurUser.IP
frmHub.DoEventsForMe
curUser.Kick()
End If
dont know the reason
snooze, you are doing a good job in your forum, congratulations
Hi hi hoo
DoEventsForMe simpy suspends executation (ie pauses thread)...it is needed before disconnecting a user because sending messages, etc need a bit of time to get sent out.
Shadows Direct Connect Hub - Taking away the light from NMDCH, leaving only shadows.....
-
- Posts: 80
- Joined: 2003-03-21 10:17
- Location: Concepcion, Chile.
I only stated what I found as a comment in a script once... so I will not vouch for its correctness
in any case, what google found on the DoEvents subject was the following:
a C implementation of DoEventsnow, I can only speculate about how VB and Jon's app work, but it wouldn't surprise me if the (chat) message sending to a user winds up in a (windows) message queue while the disconnect is immediate.
(the whole 'pause' argument does not sound like a real explanation)
in any case, what google found on the DoEvents subject was the following:
a C implementation of DoEvents
Code: Select all
MSG msg;
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {
DispatchMessage( &msg );
}
(the whole 'pause' argument does not sound like a real explanation)
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
VB's definition
Perhaps "pause" was the wrong word, but that is what I was trying to say =p. DoEventsForMe is just a wrapper function so that VBScripts can access the DoEvents function.
Code: Select all
Function DoEvents() As Integer
Member of VBA.Interaction
Yields execution so that the operating system can process other events
Shadows Direct Connect Hub - Taking away the light from NMDCH, leaving only shadows.....
Anyways you're right too....I would say the message DOES get queued. However you need to yield the threads execution for a moment so that the message gets sent before you disconnect the user.
Shadows Direct Connect Hub - Taking away the light from NMDCH, leaving only shadows.....
-
- Posts: 210
- Joined: 2003-01-23 17:24
- Location: Nevada
- Contact:
DoEvents is commonly used to ensure messages are sent, but it is not its only use, not even in DC scripting. Here is an example of DoEvents not related to message delivery :
If the sub encounters a particularly large dictionary, it will take a break every 75 processed keys, and "give the hand" to the operating system, so it can process events that occured and have been queued during the time it took to process the 75 keys... Once these events are done, the "hand" goes back to the script for another 75 keys, etc etc.
That's what DoEvents is intended for : give a small coffee break to whichever script/program/thread called the DoEvents and take care of pending buisness that piled up in other places before resuming execution of the thread that called the DoEvents. Works great to have a NMDC hub send out these messages to users before they are kicked, but DoEvents was never designed specifically for NMDCH in general, or message handling in particular =)
Code: Select all
Sub DictClean(objDict)
Dim x, aClean
aClean = objDict.Keys
For x = 0 to objDict.Count-1
If Not colUsers.Online(cstr(aClean(x))) Then objDict.Remove(aClean(x))
If x Mod 75 = 0 Then frmHub.DoEventsForMe
Next
End Sub
That's what DoEvents is intended for : give a small coffee break to whichever script/program/thread called the DoEvents and take care of pending buisness that piled up in other places before resuming execution of the thread that called the DoEvents. Works great to have a NMDC hub send out these messages to users before they are kicked, but DoEvents was never designed specifically for NMDCH in general, or message handling in particular =)
so i was right in assuming that it pass control to other program(treads).
but still it is use to induce a pause and in some cases you also help other programs responsiveness.
is there any other way to use DoEventForMe, else then in your exemple?
to extend the time of the pause.
adding 2 or 3 DoEventForMe, one after the other?
but still it is use to induce a pause and in some cases you also help other programs responsiveness.
is there any other way to use DoEventForMe, else then in your exemple?
to extend the time of the pause.
adding 2 or 3 DoEventForMe, one after the other?
-
- Posts: 210
- Joined: 2003-01-23 17:24
- Location: Nevada
- Contact:
While you can look at it as a pause, it is however not a "timed" pause for a fixed amount of (mili)seconds, but clearly a hold in the original thread to go "Do" the "Events" that pilled up while it was executing...
If you put 2 DoEvents in a row, the first DoEvents will hold/pause your script for a little while while the operating system processes everything that has been queued since it last had the hand... The second DoEvents will technically do the same and hold/pause the script again, but since the operating system just processed everything that was pending, your second DoEvents will have little to no effect.
If you get busy and caught in some RL stuff, and let your dishes pile for a day or two, it will take a lill bit to wash them all... But the next thing you do right after you're done washing the dishes is head back to the sink to do the dishes again, you'll only meet an empty sink with all the dishes already cleaned.. Need to do some cooking first before you can wash them again =)
If you put 2 DoEvents in a row, the first DoEvents will hold/pause your script for a little while while the operating system processes everything that has been queued since it last had the hand... The second DoEvents will technically do the same and hold/pause the script again, but since the operating system just processed everything that was pending, your second DoEvents will have little to no effect.
If you get busy and caught in some RL stuff, and let your dishes pile for a day or two, it will take a lill bit to wash them all... But the next thing you do right after you're done washing the dishes is head back to the sink to do the dishes again, you'll only meet an empty sink with all the dishes already cleaned.. Need to do some cooking first before you can wash them again =)
understood
else than counting sheeps , what else can be done to extend the delays before other commands is execute?
like in InnerCity exemple, but without using to much cpu sicle or slowing the script to much.
i suspect that the more speedy the puter is, the more you get chance for problems, like InnerCity have, to happens.
else than counting sheeps , what else can be done to extend the delays before other commands is execute?
like in InnerCity exemple, but without using to much cpu sicle or slowing the script to much.
i suspect that the more speedy the puter is, the more you get chance for problems, like InnerCity have, to happens.
-
- Posts: 210
- Joined: 2003-01-23 17:24
- Location: Nevada
- Contact:
You can use a timer (set it to 2 seconds, and keep it turned off), and put the 2 "batches" of commands in 2 different subs. Also declare a global variable at script level to keep track of the timer :what else can be done to extend the delays before other commands is execute?
1) Launch the sub that will execute the first batch of commands, and at the end of the sub, turn the timer on.
2) In your timer sub, each time the sub gets executed, increment the global variable, and keep track of it. For example, if it reaches 5, it means 10 seconds elapsed (i.e. the timer event that happens every 2 seconds was launched 5 times).
When enough time has elapsed, turn the timer off, set your global variable to 0, and from the timer sub, launch the second sub :
3) The second sub, containing the second batch of commands will execute.
It's the method I used in the SDCH version of BlackJack/Pontoon, for example, to give users x seconds to join a new game.
Another method is to send your script on a big loop where it will repeat some dummy operation a million times. However, this won't work as well because different CPUs will take different times to process the loop, and make the pause vary a great deal from one computer to another. It will also tie up your CPU and a great deal of resources in general; which is something the timer method doesn't do (not to the same extent anyway).
i've got a hub where music and films are forbidden, searchkick is implemented in general bot .241, but after one or two days running the hub (not refreshing/restarting the computer) it let users connect with shareds plenty full of music, i decided to separate these two scripts, deleted searchkick inside general bot and started running separated, then searchkick works fine now but...the messages are not sent before users are kicked...this happens in my AMD1.800XP, but when the hub runs in the 500 Mhz of a friend also some of the basic general bot messages are not sent (not enough slots and similar). i receive mails of users asking why they cant connect to the hub (as they dont know the reason of disconnect they dont know what detail of their configuration need to change)...the question of the messages is very important,i think, dont mind if script works slow, the important is if script work fine, so i would like to have a basic-timer-function to be called before some instructions
all scripts really work when the user connect (general bot check the configuration, searchkick look for bad files, bulletin data shows its welcome message, the onjoin...), my friend, the one that have the 500 Mhz, says: "when a new user connects my CPU usage is 40%"...O_o, so there must be a way of avoid a scripts-bottleneck that results in a bad working of all of them
and was thinking if changing this "tmrScriptTimer.Interval=60000" to a higher value...¿?¿?¿ what is the utility of this instruction?
all scripts really work when the user connect (general bot check the configuration, searchkick look for bad files, bulletin data shows its welcome message, the onjoin...), my friend, the one that have the 500 Mhz, says: "when a new user connects my CPU usage is 40%"...O_o, so there must be a way of avoid a scripts-bottleneck that results in a bad working of all of them
and was thinking if changing this "tmrScriptTimer.Interval=60000" to a higher value...¿?¿?¿ what is the utility of this instruction?
Hi hi hoo