Questions tagged [deferred-execution]
219 questions
4
votes
6 answers
Will Dispose be called first and cause a failure in case of deferred execution?
There are two methods, one of which returns a data using LINQ within a using statement. I wonder if it's possible for the query to throw some sort of an exception because the query execution is deferred and a variable it's using has already been…

Schultz9999
- 8,717
- 8
- 48
- 87
4
votes
2 answers
Are external async/defer javascripts guaranteed to execute before the window onload event?
By my understanding async scripts are executed before document parsing finished and defer scripts after that. But what about their relation to the window.onload event?
If I understand correctly async scripts are guaranteed to run before window…

Tom
- 7,515
- 7
- 38
- 54
4
votes
1 answer
Converting IEnumerable to Dictionary
after adding bool distinct to method Splitter and checking if distinct is true the code broke. The quesry now instead of being dictionary is IEnumerable, but whould be Dictionary. How could it be solved?
This is the…

Ken'ichi Matsuyama
- 359
- 5
- 20
4
votes
1 answer
Implementing deferred execution in Lua?
I've been wondering whether it was possible to implement deferred execution, .NET Linq-style, in Lua, just for funsies.
In .NET, we can create a sequence of elements known as an IEnumerable. These elements can then be filtered through various means,…

Dan
- 10,282
- 2
- 37
- 64
4
votes
4 answers
"Deferred Callback" in Objective C
I believe what I'm trying to do is referred to as a "deferred callback" at least in some paradigms.
Basically I need a way to call a method after another method returns. Something like this:
- (void)someMethod:data
{
[someObject…

anthropomo
- 4,100
- 1
- 24
- 39
4
votes
1 answer
Streaming WCF large number of objects
I am faced with writing a WCF server running on an IIS to be consumed by other platforms on different computers. I need to return a large number of objects (serialized) to the clients. I need it to be streaming since getting all of the data from…

Zohar Levin
- 2,364
- 3
- 19
- 24
4
votes
1 answer
jQuery - Deferreds waiting for an array of ajax requests to complete even failures
How can execute a function after a number of ajax requests have all completed regardless of whether they succeeded or error-ed out?
I've been trying to use $.when.apply(this, array) to pass an array of deferred jqXHR objects. However just like the…

berg
- 614
- 3
- 9
- 23
3
votes
3 answers
When to force LINQ query evaluation?
What's the accepted practice on forcing evaluation of LINQ queries with methods like ToArray() and are there general heuristics for composing optimal chains of queries? I often try to do everything in a single pass because I've noticed in those…

David K.
- 6,153
- 10
- 47
- 78
3
votes
1 answer
Deferred execution vs ToList gives different results
I'm in the middle of unit testing a function I wrote to search a queryable of items. I just assert that I get 1 item back, which I should get if the method works. But I get 0 items back. In my method I use deferred execution and just use ToList…

Oskar Kjellin
- 21,280
- 10
- 54
- 93
3
votes
2 answers
What does "object is enumerated" mean in C#?
I've been reading lately articles and documentation about deferred execution, LINQ, querying in general etc. and the phrase "object is enumerated" came up quite often. Can someone explain what happens when an object gets enumerated?
Example…

marijuslau
- 148
- 1
- 10
3
votes
2 answers
Why does it take more time when you run a LINQ OrderBy before Select?
While writing a solution for a coding problem I discovered an interesting behavior of my LINQ statements. I had two scenarios:
First:
arr.Select(x => x + 5).OrderBy(x => x)
Second:
arr.OrderBy(x => x).Select(x => x + 5)
After a little bit of…

niklasstoffers
- 33
- 2
3
votes
1 answer
Reusing an IEnumerable results in false result, e.g. on .Any()
I'm a little lost in deferred execution land:
I declare an instance of an IEnumerable implementing class
var wordEnumerable = new WordEnumerable(_text);
Then I iterate over it (the first word is "Lorem")
foreach (var word in wordEnumerable)
…

Jörg Battermann
- 4,044
- 5
- 42
- 79
3
votes
1 answer
How much information does the deferred library allow a packaged function access to?
I know that if I defer a function and pass some args to it, the function has those args and can work with them, but can a function that's part of an instanced object (for example) access the variables of its object?
class foo (object):
def…

Milo
- 335
- 4
- 15
3
votes
3 answers
Does the non-generic version of IEnumerable support deferred execution?
If so, on what .NET Framework versions is it supported?
I have tested this on .NET Framework 4.0 and it works fine:
using System;
using System.Collections.Generic;
public class TestClass
{
public IEnumerable Defer()
{
yield return…

Edgar Gonzalez
- 1,862
- 1
- 15
- 19
3
votes
2 answers
Multiple enumeration of IEnumerable - StackOverflowException
An interesting problem with IEnumerable and Linq.
static void Main(string[] args)
{
var subject = "#Accountancy #premier #Agile #Apache #automation #Automation #banking #Banking #bankIngs #AutoMation";
var hashtags =…

Alex M
- 2,410
- 1
- 24
- 37