Questions tagged [deferred-execution]
219 questions
1
vote
2 answers
Using LINQ .Select() to cast into new type is TOO slow?
Current project, broke head over this problem:
Client Repository:
public class ClientRepository
{
// Members
private masterDataContext _db;
// Constructor
public ClientRepository()
{
_db = new masterDataContext();
…

vvohra87
- 5,594
- 4
- 22
- 34
1
vote
1 answer
Remove file on function failure
If I run this code:
package main
import "os"
func pass() bool { return false }
func main() {
f, e := os.Create("file.txt")
if e != nil {
panic(e)
}
defer f.Close()
if ! pass() {
e := os.Remove("file.txt")
if e !=…

Zombo
- 1
- 62
- 391
- 407
1
vote
4 answers
How to defer computation in C++ until needed?
In C++(*), is it possible to have a structure that "defers" some computation until needed (and maybe never does the computation if not necessary)? My use case is as follows: I have roughly a dozen bool variables, each of which is computed with some…

Matt
- 952
- 2
- 8
- 17
1
vote
3 answers
Why the extension method of where for LINQ in this code would print out a single number while it shouldn't print anything at all?
I've been reading about deferred evaluation of LINQ in the "Programming C#" book by Ian Griffiths. Deferred evaluation was explained through an example in which a Fibonacci method is defined to return a never-ending sequence.
//code 1
static…

Mahsa
- 362
- 2
- 15
1
vote
2 answers
Deferring function call in argument in python 3
I'm trying to add a cache of sorts to an expensive function using a fixed dictionary. Something like this:
def func(arg):
if arg in precomputed:
return precomputed[arg]
else:
return expensive_function(arg)
Now it would be a…

TheEnvironmentalist
- 2,694
- 2
- 19
- 46
1
vote
3 answers
Why is there a different runtime behaviour with deferred execution using the "yield" keyword in c#?
If you call the IgnoreNullItems extension method in the sammple code below the deferred execution works as expected however when using the IgnoreNullItemsHavingDifferentBehaviour the exception is raised immediately. Why?
List testList =…

Raffael Zaghet
- 93
- 6
1
vote
0 answers
How to make sure that the following recursive function is resolved or completed and then do some operations?
i made a recursive function which will get the file details from a share point document library recursively but unable to know whether the recursive function is resolved or completed
//function definition
getFiles = function…

srinath
- 43
- 4
1
vote
1 answer
finalizing / post-processing chained methods
Assuming I have an Array-like object which allows for chaining methods like so:
var ds = new DataSet(items);
var subset = ds.filter(condition1).filter(condition2);
Is there a way to execute code after the last method in the chain has been processed…

AnC
- 4,099
- 8
- 43
- 69
1
vote
0 answers
How does the implementation of range-v3's meta::defer work?
Here is the implementation of meta::defer:
template class C, typename... Ts>
struct defer : detail::defer_ {};
detail::defer_
template class C, typename... Ts>
using defer_ =…

Chen Li
- 4,824
- 3
- 28
- 55
1
vote
0 answers
Why does deferred execution repeat itself on the same elements, instead of reading from a cache?
I understand the general idea of what deferred execution is in terms of a collection, but...in the context of .NET, what does that have in common with reconstructing the same elements of a collection over and over again, instead of reading from a…

Panzercrisis
- 4,590
- 6
- 46
- 85
1
vote
1 answer
How can I determine when the differed execution will end so that I can load the data in AngularJs?
I'm keeping track of the current culture using localisation cookie. I want to load all the messages for the currently selected culture when the application starts and keep them in localStorage together with information about their culture, then…

van
- 367
- 4
- 13
1
vote
1 answer
Deferred execution linq c# Tolower toupper tostring
Im wondering when I do this:
IQueryable customers = new IQueryable();
var customers = db.customers.Where(x=> x.Name.ToLower() == "john");
Does the deferred execution stop at the use of methods like "ToLower() or ToUpper or…

Viking
- 465
- 3
- 15
1
vote
0 answers
LINQ To Entities returns list data in the wrong order
I have the following query, using the entity framework:
var results = (
from v in SomeTable
select new
{
Something = new List { "A", "B", "C" }
});
The resulting output is:
A,B,C
C,B,A
A,B,C
C,B,A
.
.
.
I can fix the problem by adding…

Moby Disk
- 3,761
- 1
- 19
- 38
1
vote
1 answer
LINQ Count method : why the query is executed again?
I have read that the LINQ is very lazy...
I have a class with a model:
class Movie
{
public string Title { get; set; }
public float Rating { get; set; }
private int year;
public int Year
{
…

Buda Gavril
- 21,409
- 40
- 127
- 196
1
vote
2 answers
Disposing DataContext/ObjectContext without breaking deferred execution code
C# 6.0 in a Nutshell by Joseph Albahari and Ben Albahari (O’Reilly).
Copyright 2016 Joseph Albahari and Ben Albahari, 978-1-491-92706-9.
brings, at page 376, a discussion on disposing DataContext/ObjectContext instances.
Disposing…

Veverke
- 9,208
- 4
- 51
- 95