Sign in to follow this  
Followers 0
qwertylol

adlib power !?

5 posts in this topic

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?

Share this post


Link to post
Share on other sites



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?

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]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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() ?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0