delegates

Application Delegate - Cocoa

Hey all, I want to incorporate an applicationDidFinishLaunching: into my cocoa delegate. How would I do this?? On the iphone SDK the applicationDidFinishLaunching is already in the application delegate, but when making my mac application I noticed that there were none. Best Regards, Kevin ...

Confusion over `Action` delegate and lambda expressions

private void StringAction(string aString) // method to be called { return; } private void TestDelegateStatement1() // doesn't work { var stringAction = new System.Action(StringAction("a string")); // Error: "Method expected" } private void TestDelegateStatement2() // doesn't work { var stringAction = new System.Action(p...

ASP.Net ListView and event handling.

I have an .ascx which contains a listview. Let's call it the parent. Within its ItemTemplate I reference a second .ascx which is basically another listview, let's call it the child. On the parent, the child control is wrapped in a placeholder tag. I use this place holder tag to show and hide the child. Psuedo code: The child...

C# Delegates and Events design help

I have some code in my project that saves an object to the database, once this is done I want it to call a series of other methods. I was thinking about allowing other methods to subscribe to this event so I can add more as I need to. The idea I had for this was to create an array of Delegates allowing other methods to register, then wh...

Castle.DynamicProxy2 generate proxy of delegate type

Is there a way to create a proxy of a delegate type and have it implement additional interfaces in DynamicProxy2 and also being able to intercept calls to the generated delegate? The way i normaly generate proxies throws an exception because delegate types are sealed. ...

C#: Action delegate vs explicit delegate

Hello Just a quick one: what are peoples thoughts on using Action delegates for public class events vs defining ones own event delegate types? I know many use Actions for "minor" delegates such as in lamdas and .ForEach() extension methods, etc, but for actual class event members, is using Actions a good idea? What is "best practice" ...

iphone sdk delegate failed to return after waiting 10 seconds in table view loading huge data from database

SendDelegateMessage: delegate failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode If you were not using the touch screen for this entire interval (which can prolong this wait), please file a bug. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { /* ...

Can I cancel methods through delegates in C#

I'd like to stop immediately a method if I press cancel in the "processing" animation screen. I'm using Async call through delegates. Is it possible to stop immediately the execution of the method through delegates? Thanks :) ...

Action delegate with more than four parameters (method arguments)

I have written a helper class which uses the Action - delegate as method parameter. Like this: public void SomeMethod(Action<T> methodToExecute, T argument); According to the MSDN you can declare max. 4 arguments on an action delegate: Action<T1,T2,T3,T4>. Now I'd like to call a method which needs 5! arguments. How could I do this? T...

AppDelegate or AppController

Hi all While reading cocoa tutorials i've noticed that some of the tutorials use AppDelegate and some AppController for defining IBActions that open various windows that use subclasses of NSWindowController. Is there some sort of rule of thumb for this? ...

Calculating expression tree with many parameters

I'm trying to use the Expression tree and Lamdba Expression objects in .Net 3.5 to allow me to dynamically calculate boolean expression entered by a user. So far a user can create an expression tree consisting of BinarayExpressions that AND and OR values expressed as ParameterExpressions. I was then planning on creating a LambdaExpressi...

Creating two delegate instances to the same anonymous method are not equal

Consider the following example code: static void Main(string[] args) { bool same = CreateDelegate(1) == CreateDelegate(1); } private static Action CreateDelegate(int x) { return delegate { int z = x; }; } You would imagine that the two delegate instances would compare to be equal, just as they would when using the good old name...

Syntax for applying an attribute to an anonymous method?

This is related to the question about return type attributes and anonymous classes, but then for anonymous methods (or lambdas), but as far I could find this exact question does not seem to be on stackoverflow yet. In code for business entities that we generate using CodeSmith we now have [DebuggerNonUserCode] attributes, so they don't ...

C# Delegate problem - what the heck does this code do?

Can anyone explain to me what the following line of C# code does? public event EventHandler<DataEventArgs<BusinessEntities.Employee>> EmployeeSelected = delegate { }; The bit that's really got me stumped is the delegate { } piece at the end. For a bit more context, the sample from the EmployeesListView.xaml.cs in the ViewInjection sam...

Passing variables from main form to input form

Hi I have a simple question. I have a main form, and then a startup form from where I can select a new 3D model to generate. When selecting a new 3D model from the startup form, I want to check first whether the previous model I worked on has been saved or not. I simply want to pass a boolean value from the main form to the startup form...

Getting a system-clock-change-tick in C#

Is their a way to execute a delegate or event in C# when for instance the seconds, minutes, hours,... change in the system-clock, without using a timer that checks every millisecond if the property has changed and executes the event with a delay of maximum a millisecond. ...

iPhone - insertSubview makes ObjectAlloc jump

Whenever I add a new viewController my ObjectAlloc jumps up really high and never comes back down. Even after calling removeFromSuperview. Is this normal? if((UIButton *) sender == gameArcadeBtn) { GameArcade *gameArcadeController = [[GameArcade alloc] initWithNibName:@"GameArcade" bundle:nil]; self.gam...

How do I use a collection to store a delegate?

I wanted to have a hashtable with a string as key and a functionpointer (delegate) as value. This way calling the correct routine given a string based command. However, the compiler won't eat it. What am I doing wrong? //declaration public delegate void categoryHandler(String request); //init code Hashtable categories ...

Is List<T> where T is an anonymous delegate possible?

Is it possible to create a list of anonymous delegates in C#? Here is code I would love to write but it doesn't compile: Action<int> method; List<method> operations = new List<method>(); ...

Getting “EXC_BAD_ACCESS” when accessing instance variable from within UITableView delegate method

My iPhone application blows up when it accesses an instance variable from within one of the UITableView delegate methods. I think I'm retaining it so I do not understand why I can't access it without a problem. Here's my .h file #import <Foundation/Foundation.h> #import "AlertSummaryCell.h" #import "AlertDetailViewController.h" @inte...