How to start a function in a new thread with a delay ?
7 posts
• Page 1 of 1
How to start a function in a new thread with a delay ?
I am trying to start a function in a new thread but with a delay of 1 second before beginning the execution. The following line does not work (nothing is executed). I could I do that ?
{⎕DL 1 ⋄ FOO}&0
Thanks in advance.
Pierre Gilbert
{⎕DL 1 ⋄ FOO}&0
Thanks in advance.
Pierre Gilbert
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: How to start a function in a new thread with a delay ?
That's for the same reason why
{[]DL 1 <> FOO }1
does not execute FOO: d-fns end execution at the first non assigned result. []DL 1 returns 1 and the execution does not proceed further. You may want to assign its result like so:
{ z<-[]DL 1 <> FOO }&1
{[]DL 1 <> FOO }1
does not execute FOO: d-fns end execution at the first non assigned result. []DL 1 returns 1 and the execution does not proceed further. You may want to assign its result like so:
{ z<-[]DL 1 <> FOO }&1
-
StefanoLanzavecchia - Posts: 109
- Joined: Fri Oct 03, 2008 9:37 am
Re: How to start a function in a new thread with a delay ?
Many thanks Stefano, it's working.
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: How to start a function in a new thread with a delay ?
As an alternative, consider delaying before launching the background thread:
{FOO}&⎕DL 1
-
Adam|Dyalog - Posts: 137
- Joined: Thu Jun 25, 2015 1:13 pm
Re: How to start a function in a new thread with a delay ?
Thanks Adam, will this way of doing will 'freeze' the current thread for 1 second before the execution of FOO starts in another thread ?
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
Re: How to start a function in a new thread with a delay ?
Yes, it will pause the main thread for a second, then continue by launching the background thread. Use whichever functionality it is you want.
-
Adam|Dyalog - Posts: 137
- Joined: Thu Jun 25, 2015 1:13 pm
Re: How to start a function in a new thread with a delay ?
Merci Adam, this is answering my question.
-
PGilbert - Posts: 436
- Joined: Sun Dec 13, 2009 8:46 pm
- Location: Montréal, Québec, Canada
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group