delegates

How do I invoke a Delegate faster than by using DynamicInvoke?

Currently I useDynamicInvokewhich is very slow. Still using theDelegatetype how can I directly invoke the Delegate without late-binding/theDynamicInvoke? Delegate _method; _method.DynamicInvoke(_args); Thanks. ...

Delegation and Modal View Controllers

According to the View Controller Programming Guide, delegation is the preferred method to dismiss a modal view. Following Apple's own Recipe example, i have implemented the following, but keep getting warnings that the addNameController:didAddName method is not found... NameDelegate.h @protocol NameDelegate - (void)addNameContr...

Error Checking using Func Delegate

So i recently learned this new trick of using Func Delegate and Lambda expression to avoid multiple validation if statements in my code. So the code looks like something like public static void SetParameters(Dictionary<string,object> param) { Func<Dictionary<string, object>, bool>[] eval = { ...

How to set a delegate in a different class

Hi, I'm working with NSXMLParser that parses a xml document. You have to set the delegate which we would be called every time the parser finds an element. The examples I've looked at all set the delegate to be the same class that's createing: NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:filename]; [parser setDelega...

C# delegate Invalidcast Exception

Hi, I am stuck with an InvalidCast Exception. I am calling a delegate to run some function. In the callback method of the delegate I am trying to get the return value of the function as shown below. public delegate SyncHelper.SyncPlan RunJobDelegate(); public static void SyncJobCallback(IAsyncResult result) { Ru...

scrollViewDidScroll not executing.

I think have decent experience working with iPhone development. as much I know.. I did set up the delegate.. I have from top to botton UIView --> UIScrollView--> UITextView I tried everything... to get the event scrollView to fire the scrollViewDidScroll event. is anything wrong with the structure.. there not much of the code to post...

Autoimport callbacks of delegate in XCode (iOS)

Hi all, as the tilte is possible autoimport or there is an option in xcode that allow to import all callbacks of a delegate(as MKMapviewdelegate or other)? I use this option in Eclipse (Java) to import getters/setters methods to access class variables. Thanks in advance. ...

Invoke method in Func when passed as parameter

Hello. I was creating a Func as parameter input to another method, but how do I invoke that? The following code describes my work: I call Foo with: Foo(x => x.SlidingExpiration(TimeSpan.FromSeconds(50))); My method Foo: public void Foo(Func<CacheExpiration, TimeSpan> cacheExpiration) { .... inside here I want to call RefreshCache,...

Delegate works without instance creation

My Two versions of the following declarations work fine. 1) Func<int,int,int> findMax=Max; Console.WriteLine("Max={0}",findMax(10,20)); 2)Func<int,int,int> findMax=new Func<int,int,int>(Max); Console.WriteLine("Max={0}",findMax(10,20)); where public static T Max<T>(T a, T b) where T:IComparable { if (a.CompareTo(b)...

Delegate confusion .. How do I find out when several delegates have finished their task?

I've built a basic Web XML to Core Data parsing system, but I am confused about how to set off several parsers at once, and know when they are all done. This is my current setup, which gets just one parsed xml file ("news"). But I have several xml files I need to parse ("sport", "shop" etc). How would set all of these off, and know when...

Executing multicast delegates in C#

I have a Multiple target Func<int,int,int> funHandler=Max; funHandler+=square; When i execute Console.WriteLine(funHandler(10,10)); it return the square of 10 (i.e) 200.It did not fire Max. i used something like foreach(var v in funHandler.GetInvocationList()) { Console.WriteLine(v(10,20)); } 'V' is a variable,but it is u...

Send message from appdelegate to view controller

Hello, I have a view (nib) loading offscreen in a uiscrollview. I want the movie in this view to only start playing once it is visible but the viewdidappear fires even the view is off screen. So the movie is playing even though you can't see it. Is there a way to understand what view is actually visible that does not involve the uiscro...

Passing delegate as method parameter

Hello, I'm currently developing an EventManager class to ensure that no events are left wired to dead WCF duplex clients, and also to control prevent multiple wiring from the same client to the one event. Now basically, I'm what stuck with is trying to pass the event delegate to a function that will control the assignment like this. va...

Why would ppl want to use Invoke() (not BeginInvoke())?

I was told that Invoke() is similar to normal method calling... so why would ppl choose to use Invoke and not normal method calling? I tried to search online regarding the issue, what i get is the advantages of using BeginInvoke(), but what are the advantages of using Invoke()? Thanks ...

Help Translating a small C# WCF app into Visual Basic

Hi - I'm trying to write a simple/small Windows Communication Foundation service application in Visual Basic (but I am very novice in VB) and all the good examples I've found on the net are written in C#. So far I've gotten my WCF service application working but now I'm trying to add callback functionality and the program has gotten mor...

how to add delegate to interface c#

I need to have some delegates in my class. I'd like to use the interface to "remind" me to set these delegates. How to? my class look like this public class ClsPictures : myInterface { // Implementing the IProcess interface public event UpdateStatusEventHandler UpdateStatusText; public delegate void UpdateStatusEve...

Why does Delegate.CreateDelegate allow for invalid conversions?

Edit: I filed a bug report on microsoft connect:: https://connect.microsoft.com/VisualStudio/feedback/details/614234/delegate-createdelegate-allows-binding-functions-with-enum-parameters-to-the-enum-base-type#details Consider the following thing: public static Int32 Test(Int16 @short) { return @short; } and from calling code:: F...

for delegates which one is better and when? how do u think in OOP?

I can declare a delegate as General type, like a public or internal types, also i can create it within a (abstract) class and make it protected, so just some classes can access to that delegate for example: delegate void PublicSample(); interface IMyInterface { event PublicSample mySample; } class Implementor : IMyInterface { ...

Assigning an IronPython method to a C# delegate

I have a C# class that looks a little like: public class MyClass { private Func<IDataCource, object> processMethod = (ds) => { //default method for the class ...

How do I add specific events to newly assigned controls in an Array [c#]

Basically I want to assign events to some controls that are created. I want to update the labels associated with each trackbar when each trackbar is changed (change label1[i] and label2[i] when trackbar[i] changes). I have waded through google and I found that this probably has be done by using delegates. I had a blast using lambda expre...