Modify

Opened 6 years ago

Last modified 6 years ago

#2673 new Feature Request

AdlibRegister(0) execute function instanly instead of after 250ms

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

In current AutoIt version, AdlibRegister with negative or zero timeout will be auto correct to 250 ms. By allowing AdlibRegister with zero parameter, user will be free to setup a dispatch for a long-time-running business function.

Think the case you need to execute long-time running function but also want to process event like button click, you cannot using an "Dummy" control because it also use the same event queue with a normal button, so your normal button click will be cached and execute after the long-time running function). Of course you can set up some code to provide work around but i think AdlibRegister is the fastest way.

Currenly I use AdlibRegister(1) to get an acceptable solution, but I think allowing AdlibRegister(0) will provide more advantage, especially in concurrency. In a heavy application, some action will be occur in 1 ms delay.

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by TicketCleanup

  • Version 3.3.8.1 deleted

Automatic ticket cleanup.

comment:2 follow-up: Changed 6 years ago by Melba23

It has been shown that running another Adlib function before the previous one has ended leads to all sorts of problems - I can also foresee disaster if you have virtually instantaneous calls.

There has to be some delay between calls - if a single millisecond is too long then I question whether you should be using AutoIt at all for the task.

M23

comment:3 in reply to: ↑ 2 Changed 6 years ago by anonymous

Replying to Melba23:

It has been shown that running another Adlib function before the previous one has ended leads to all sorts of problems - I can also foresee disaster if you have virtually instantaneous calls.

Please correct me if I am wrong, I think AutoIT never allow 2 Adlib 'terminate' another, like event, the later registered Adlib/event need to wait for the previous function ends. And the problem often is, when two event/Adlib is called when the previous one has not finished yet, then the script queue the event/Adlib and call it right after the previous ends instead of execute the main script. In case of event, since you only make an event by interacting with the GUI, you can only create a limited number of events. But with Adlib, the disaster is that Adlib function may be called with an infinite times and the will never return to the main script. You will have an infinite loop then.

I often do a trick, unregister the adlib right after you enter the function. This make the adlib be called exactly once.

There has to be some delay between calls - if a single millisecond is too long then I question whether you should be using AutoIt at all for the task.

A simple case that the user double click the button instead of single click. This action often occurs. I think AutoIT rely on the mouse up to fire event and do not check if it's double click to filter later mouse up message, so the event will fire twice. And, together with a not expected side effects of the AutoIT 'virtual multithread' (temporarily terminate a function and execute another, then return to previous function), the event function is called twice continously, instead of drop the later event. Think the case your user click the button process a 500-1000 lines documents in 5s. During that time, your user mis-click the button 3 more times , and, without a notes, your application repeat the process action 4 times. Ouch! And I have meet application, which user click the close button when another event is processing. The application does not respond to the click event, but suddenly quit right after the long time running event ends.

A workaround, as suggest somewhere in our forum, is having a global variable to check 'busy' state. The check operation is placed in begins of the Adlib function. This may lead to a situation that another code can modify this variable before 1ms delay, and create other problems. So by allow 0ms delay, we have the benefit of the CriticalSection immediatly, make script more reliable.

Finally, I think use Adlib may lead to the disaster, why not make it also lead to the candy? Banning 0ms timeout prevents the user to create a infinite Adlib loop directly, but an user can easily create it indirectly by give a long time running Adlib function, or using Sleep, which make Adlib's excute time longer than the interval. I think it's not a technical problem when change this behavior, so this change may be easy. And, this change does not break the AutoIT design pattern and workflow.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as new The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.