qwertylol Posted April 28, 2007 Share Posted April 28, 2007 If I want to have a tcp server listening for connection, a traymenu to control the script, and while nothing is happening have the script perform tasks, should I do something like this? Adlib ("tcp_functions", 100) ;also a problem on how often this should run to catch all connections. Adlib ("other tasks", 100) While 1 $msg = Traygetmsg() Wend so the only thing I keep in a fast loop in the control, the onevent $msg? Link to comment Share on other sites More sharing options...
Achilles Posted April 29, 2007 Share Posted April 29, 2007 If I want to have a tcp server listening for connection, a traymenu to control the script, and while nothing is happening have the script perform tasks, should I do something like this?Adlib ("tcp_functions", 100) ;also a problem on how often this should run to catch all connections.Adlib ("other tasks", 100)While 1 $msg = Traygetmsg()Wendso the only thing I keep in a fast loop in the control, the onevent $msg?I'm not positive but I think you can only have one adlib running at once. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 29, 2007 Share Posted April 29, 2007 Piano_Man is correct, there is only one AdLibEnable() going at a time. Running AdLibEnable() again replaces the previous settings. You can, however, get that one function to dispatch as many other functions as you want by check TimerInit()/TimerDiff(). This demo does one thing every 100ms, and another every 2sec: Global $Timer = TimerInit() AdlibEnable("_TimeCheck", 100) While 1 Sleep(20) WEnd Func _TimeCheck() _FunctionOne() ; This happens every 100ms If TimerDiff($Timer) > 2000 Then _FunctionTwo() ; This only happens every 2sec $Timer = TimerInit() EndIf EndFunc ;==>_TimeCheck Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
qwertylol Posted April 29, 2007 Author Share Posted April 29, 2007 yeah. but my main concern is, would the functions be as responsive as when they were run alone? for instance, would a server script miss messages because its listen call only occurs every 2 seconds? also the traymenu, same problem, is it possible that it would not create the list I wrote because it's the wrong moment to right click it? or a bad timing for $msg = TrayGetMsg() ? Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 29, 2007 Share Posted April 29, 2007 but my main concern is, would the functions be as responsive as when they were run alone? for instance, would a server script miss messages because its listen call only occurs every 2 seconds? also the traymenu, same problem, is it possible that it would not create the list I wrote because it's the wrong moment to right click it? or a bad timing for $msg = TrayGetMsg() ?Messages for most sources are que'd or buffered somewhere. If 2sec is too slow for you server script, check it every 1sec, or 200msec, or whatever is good enough. Keep in mind that server response timeouts are usually more like 30sec or even 1min. What I was trying to demo in the demo was that the same AdLibEnable function can dispatch several others on varying times. It could dispatch your server port check every 500ms and check TrayGetMsg() every 100ms. Or whatever times work for you. The point is, it only takes one dispatch function to do it. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now