deferred-execution

How to maintain LINQ deferred execution?

Suppose I have an IQueryable<T> expression that I'd like to encapsulate the definition of, store it and reuse it or embed it in a larger query later. For example: IQueryable<Foo> myQuery = from foo in blah.Foos where foo.Bar == bar select foo; Now I believe that I can just keep that myQuery object around and use it like I describe...

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? ...

Prioritize JavaScript Scripts: Defer Not Working

I need to prioritize scripts so jQuery, Cufon, and my .js files come before Twitter does. I've tried defer="defer" as well as placing scripts in the bottom in the order I want them to execute but all these methods aren't working. I don't want to modify Twitter's files either. Anything I can do? ...

Chaining Deferred Tasks with Google App Engine

I have a website I am looking to stay updated with and scrape some content from there every day. I know the site is updated manually at a certain time, and I've set cron schedules to reflect this, but since it is updated manually it could be 10 or even 20 minutes later. Right now I have a hack-ish cron update every 5 minutes, but I'd li...

How to defer a Django DB operation from within Twisted?

I have a normal Django site running. In addition, there is another twisted process, which listens for Jabber presence notifications and updates the Django DB using Django's ORM. So far it works as I just call the corresponding Django models (after having set up the settings environment correctly). This, however, blocks the Twisted app, ...

Persistence of deferred execution linq expressions

We're trying to serialize some data, and one of the items in a collection is a "deferred execution linq statement" (actually it's the result of a Concat call on a collection). The problem is how to persist that object. It doesn't support ISerializable. The actual type is something along the lines of System.Linq.Enumerable.WhereSelectLi...

What methods can I use to rearrange the order of javascript function execution?

How to rearrange javascript function execution order independent of include order. A question that assists, but doesn't completely answer my question: Can you have multiple $(document).ready(function() sections? (The answer is yes, and they execute in the order that they are added to jQuery.ready()). I am trying to make my javascript ...

C#, NUnit: How to deal with testing of exceptions and deferred execution

Say we have a method that looks like this: public IEnumerable<Dog> GrowAll(this IEnumerable<Puppy> puppies) { if(subjects == null) throw new ArgumentNullException("subjects"); foreach(var puppy in puppies) yield return puppy.Grow(); } If I test that by doing this: Puppy[] puppies = null; Assert.Throws<Argumen...

Will adding partial class properties ruin deferred execution?

If I add properties onto a linq entity (employees for example), that simply refer to other properties to implement an interface, return an IQueryable, and the where clause mentions those added properties that just point to other linq entity properties, will it cause the entire table to be loaded and filtered in memory instead of at the s...

Resolving associated objects in SL4 RIA

Having created a standard Silverlight Business Application in VS2010 and set up a model from a SQL Server database, I have various entities and associations, among which AssetGroup and Asset are in a 1:m relationship. Allegedly I can use dot notation to get the associated AssetGroup out of an asset instance. Through the modern miracles ...

Why can't a Deferred be passed to a callback in Python Twisted?

d = Deferred() d.callback(Deferred()) # Assertion error saying that a Deferred shouldn't be passed Why is this? I looked through the code and commit messages / Trac and see no reason why this should be the case. The most obvious way to bypass this is to put the Deferred in a tuple, but why is this restriction here in the first place? ...

How to defer execution of an Event on each item in a collection until iteration of collection is complete using delegates and/or events?

Of Note: This is more of a curiosity question than anything else. Given a List<Window> where each window has an event attached to the Close Event which removes the window from the collection, how could you use delegates / events to defer the execution of the Close Event until the collection has been iterated? For example: public class...

How can I evaluate a deferred Linq statement when debugging?

I'm debugging in VS2010, and I want to inspect a string value but all I can get the debugger to show me (through watches, hovering, locals, etc.) is: "System.Linq.Enumerable+<TakeIterator>d__3a`1[System.Char]" I don't care if there are side effects from premature evaluation or whatever, I just want to see what the expression would ev...

yield returns within lock statement

Hi eveybody, 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<string> _data = new List<string>(){"1","2","3","4","5"}; private object _locker =new object(); public IEnumerable<string> GetData(...

How can i mock or test my deferred evaluation/execution functionality?

I have what could be seen as a bizarre hybrid of IQueryable<T> and IList<T> collections of domain objects passed up my application stack. I'm trying to maintain as much of the 'late querying' or 'lazy loading' as possible. I do this in two ways: By using a LinqToSql data layer and passing IQueryable<T>s through by repositories and to m...

Child sProc cannot reference a Local temp table created in parent sProc

On our production SQL2000 instance, we have a database with hundreds of stored procedures, many of which use a technique of creating a #TEMP table "early" on in the code and then various inner stored procedures get EXECUTEd by this parent sProc. In SQL2000, the inner or "child" sProc have no problem INSERTing into #TEMP or SELECTing data...

Deferred execution of List<T> using Linq

Say I have a List<T> with 1000 items in it. Im then passing this to a method that filters this List. As it drops through the various cases (for example there could be 50), List<T> may have upto 50 various Linq Where() operations performed on it. Im interested in this running as quickly as possible. Therefore, i dont want this List<T> f...

garbage collection in a linq query

I have a question about how garbage collection might be handled in a linq query. Suppose I am given a list of requests to process. Each request generates a very large set of data, but then a filter is applied to only keep critical data from each requested load. //Input data List<request> requests; IEnumerable<filteredData> results = re...

How to interpret this execution plan (IN vs EXISTS)?

It looks like from the execution plan the IN version is faster than EXISTS version I'm thinking that EXISTS query is faster, for it eagerly checks the conditions. The IN query though it looks intuitive, I feel that it seems it resolves the final conditions' result very late; that is, from inside out, I perceived that IN are slower beca...

Linq: Xml to IEnumerable<KeyValuePair<int, string>> deferred execution?

I'm trying to pull out the Roles below into an IEnumerable<KeyValuePair<int, string>> <PROJECT PROJECT_NO="161917"> <CONTACT CLIENT_ID="030423253272735482765C" CONTACT_NO="1"> <ROLE ROLE_ID="2" ROLE_DESC="ARCHITECT" /> <ROLE ROLE_ID="5" ROLE_DESC="INTEGRATOR" /> </CONTACT> </PROJECT> private static ProjectContact Buil...