Questions tagged [deferred-execution]
219 questions
33
votes
2 answers
In go, is there a way to execute code on termination of the program?
I know you can define functions called init in any package, and these function will be executed before main. I use this to open my log file and my DB connection.
Is there a way to define code that will be executed when the program ends, either…

Fabien
- 12,486
- 9
- 44
- 62
32
votes
2 answers
yield returns within lock statement
if i have a yield return in a lock statement does the lock get taken out on each yield (5 times in the example below) or only once for all the items in the list?
Thanks
private List _data = new List(){"1","2","3","4","5"};
…

DayOne
- 1,027
- 1
- 11
- 16
31
votes
6 answers
Linq - What is the quickest way to find out deferred execution or not?
What is the quickest way to find out which .net framework linq methods (e.g .IEnumerable linq methods) are implemented using deferred execution vs. which are not implemented using deferred execution.
While coding many times, I wonder if this one…

Tejas
- 1,011
- 3
- 11
- 16
26
votes
3 answers
Why does `defer recover()` not catch panics?
Why does a call to defer func() { recover() }() successfully recover a panicking goroutine, but a call to defer recover() not?
As an minimalistic example, this code doesn't panic
package main
func main() {
defer func() { recover() }()
…

jinpan
- 390
- 4
- 10
23
votes
1 answer
When using yield within a "using" statement, when does Dispose occur?
I have a question regarding deferred execution and the disposing of data.
Consider the following example:
private IEnumerable ParseFile(string fileName)
{
using(StreamReader sr = new StreamReader(fileName))
{
string line;
…

Middas
- 1,862
- 1
- 29
- 44
21
votes
1 answer
What is a browser event loop?
I have been doing some web application programming using GWT and have been confused by the term "browser event loop".
I have encountered situations where I need to execute deferred commands and "do something" after the browser event loop…

gofeddy
- 579
- 8
- 20
20
votes
1 answer
Understanding jQuery Deferred.pipe()
I am trying to implement the jQuery Deferred.pipe() method for the following scenario:
Add a user in DB via $.ajax()
Get response whether user was added correctly or not.
If successfully added, get all the user list from server via $.ajax()
Display…

Ashish
- 2,544
- 6
- 37
- 53
18
votes
2 answers
Executing a trigger AFTER the completion of a transaction
In PostgreSQL, are DEFERRED triggers executed before (within) the completion of the transaction or just after it?
The documentation says:
DEFERRABLE
NOT DEFERRABLE
This controls whether the constraint can be deferred. A constraint
that is not…

Mehran
- 15,593
- 27
- 122
- 221
17
votes
3 answers
How to execute Ant build in command line
I have an Ant build file, and I try to execute it in the command line with the following command:
$ C:\Program Files (x86)\.....>ant -f C:\Silk4J\Automation\iControlSilk4J\build.xml
But nothing happens, and the result is:
BUILD SUCCESSFUL
Total…

Guylene Emond
- 251
- 2
- 4
- 7
17
votes
2 answers
When to use LINQ's .ToList() or .ToArray()
After running this code:
var input = new List( ... );
var result = input.Select( t => new U(t) );
U first1 = null;
foreach ( U u1 in result )
if ( first1 == null )
first1 = u1;
U first2 = null;
foreach ( U u2 in result )
if (…

HappyNomad
- 4,458
- 4
- 36
- 55
15
votes
6 answers
Deferred execution in C#
How could I implement my own deferred execution mechanism in C#?
So for instance I have:
string x = DoFoo();
Is it possible to perform some magic so that DoFoo does not execute until I "use" x?

Larsenal
- 49,878
- 43
- 152
- 220