Old 06-18-2015, 01:58 PM   #1
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default stop running specific defer()

Hi guys.
Sorry if this question is too stupid.

Is there any way to run and exit different defer()-based scripts?

Example.
1. Run first script with defer(). It works in background.
2. Run second script with defer(). It also works in background.

How to stop first defer with atexit()?
mpl is offline   Reply With Quote
Old 06-18-2015, 02:29 PM   #2
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by mpl View Post
Hi guys.
Sorry if this question is too stupid.

Is there any way to run and exit different defer()-based scripts?

Example.
1. Run first script with defer(). It works in background.
2. Run second script with defer(). It also works in background.

How to stop first defer with atexit()?
Using ExtState (SetExtState, GetExtState etc...) to share variables across scripts. Change variable in one script and read it in the other. Depending on it's value continue deferring or stop.
Breeder is offline   Reply With Quote
Old 06-18-2015, 02:39 PM   #3
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

Ok, using variables as conditions to run atexit. Thank you fo this simple solution.
So, atexit in one script doesn`t stop defer in other script in any situation (i mean, IDE run scripts in different threads, and these defers have own id somehow)?
mpl is offline   Reply With Quote
Old 06-19-2015, 01:39 AM   #4
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Posts: 2,436
Default

Quote:
Originally Posted by mpl View Post
So, atexit in one script doesn`t stop defer in other script in any situation (i mean, IDE run scripts in different threads, and these defers have own id somehow)?
Not sure I understand your question.

Each script is an entity in itself and it doesn't affect other scripts. Atexit and defer in one script are different from the same things in some other script. Btw, they are not run in different threads. Defers simply defers the execution to a timer. So for each timer tick, all defered functions are ran once more (in consequtive order, not all at once) and when run they may get defered by script again so they are again run at next timer tick etc...until you either close the script or stop deferring from within the script.
Breeder is offline   Reply With Quote
Old 06-19-2015, 02:08 AM   #5
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

Yes, I was interested by thing you explained. Thank you again.
mpl is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.