delegates

Are C++ Constructor delegates already available in VS2008?

Hello there SOers, I cant seem to find any useful information whether constructor delegates that are proposed for C++0x are already available in Visual Studio 2008 / 2010. I tried to use them and got pretty strange errors, but I can't test this in VS2010 currently. Can anyone tell me if they are available already? cheers, Tom ...

How can I dismissModalViewController when a user hits GO?

I have a view and a button. When the button is pushed, I present a modal view controller that has a uiwebview, and a navigation bar at the top. The hardcoded uiwebview shows a login prompt. Once the user goes in and enters the correct login credentials and hits GO on the keyboard, I not only need it to authenticate me into the server, bu...

Returning IEnumerable with using

Interesting problem I ran across which makes total sense. I have a generic method like so: public TResult Run<TResult>(Func<SqlDataReader, TResult> resultDelegate) { TResult result; using (SqlDataReader reader = command.ExecuteReader()) // command is SqlCommand with attached SqlConnection { result = resultsDelegate(read...

Should I use List<IObserver> or simply Action<T> to keep track of an IObservable's subscribers?

I'm implementing the IObservable<T> interface on some classes. I used Reflector to figure out how this is typically done in Rx. Concerning how an observable keeps track of its subscribers and notifies them via their OnNext method, I stumbled upon code similar to this: private List<Observer<T>> observers; // subscribe a new observer: pu...

Best way to pass data between objects in iphone development?

I am working on an iphone application and don't know what the best way to hold temporary data across views. for example i have xml on a server and i parse the data into an object so that I can hold the information. The xml has some data that i want to be displayed on one view and other data that i want to be displayed on another view. I ...

Is MulticastDelegate.CombineImpl inefficient?

I just fired up Reflector and peered into MultiCastDelegate.CombineImpl and saw some very lengthy code... every time two delegates are combined (read: every time you attached more than one event handler to an event), the following code gets run, which seems inefficient for such a fundamental performance critical feature. Does anyone k...

why does (sender,e) => SomeAction() works on winforms and not in asp.net

Hello, I have the following code: btnTest.Click += (sender,e) => SomeAction() why does this code works in WinForms and not in asp.net. In asp.net I had to do the following: btnTest.Click += new EventHandler(SomeAction); target framework in both cases is .net 4.0 ...

Objective C - Strategy Pattern ???

I understand the concept of the "strategy pattern" but i am still a little bit confused. Let'say we have a class named Dog Dog has MovementBehaviour (interface) which can be MovementBehaviourNormal & MovementBehaviourFast MovementBehaviourNormal and MovementBehaviourFast both contain a method named move QUESTION: what is the best way t...

Delegates - Functionality

I am new to iPhone development, just started learning on my own. While proceding i came up with a word Delegate. Can any one please explain them to me with an example. ...

Run delegate method with BeginInvoke

Hi, In my class I have a staic method publis static void DoWork(int param) ... I want to run that method like: Form.BeginInwoke(DoWork, param); Is that possible? I tryed with the MethodInvoker class ... but I don't want to define the method body inline. Is there any generic delegate? Or do you know any other way of calling this ... w...

Generic parameter delegate?

I'm a bit fuzzy on the new Action/Func/Variance/CoVariance stuff, which is probably what I need. What I want is to be able to pass a delegate as a parameter to a method, that takes a string and returns a bool. The problem is that I can't use a typed delegate or interface since it will be used in different libraries which doesn't share l...

Recursive call - Action lambda

What am I doing wrong here? How can I execute my action? var recurse = new Action<IItem, Int32>((item, depth) => { if (item.Items.Count() > 0) recurse(item, depth + 1); // red squiggly here // ... }); I'm getting a red squiggly when calling recurse saying "method, delegate or event expected". ...

trying to set a delegate method to get urlConnection data.

I've been going around and around, I've been trying to use this example but running into trouble in the delegate method. I'm trying to figure out how to close this out. Looks like I've got a lot set correctly but need help on final step: I'm getting a -[ThirdTab apiFinished:]: unrecognized selector sent to instance. On line two o...

Compare Dictionary<string,List<object>>

I am comparing two dictionary(dic1 and dic2) with rule that get values from dic2 where key match but values does not match or key is missing in dic2. Don’t need to iterate through dic2 for missing/different values in dic1. Below code is working ok I would like to know is there any better way using .NET 2.0 (NO LINQ) . if optimization...

MKMapView: message sent to deallocated MKMapViewDelegate

This is a mysterious bug for me. I suspect the issue is burried somewhere in IB or my code, but so far I haven't been able to find anything suspicious. Hopefully one of you more experienced developers have run across a similar issue and can point me in the right direction. I have a view set up in IB, and I have a subclassed MKMapView ad...

Async Updating of UI when an exception occurs in referenced DLL

Hello All, I have a winapp running with a DLL referenced to it. all the major operations are done in the DLL. I have like 1000 xml files stored in a location which i have to read and store data into another format. From the UI, i click on an import button, the call is passed to the DLL layer which converts one xml after another stored...

Convert B(C(),D()) to (c,d)=>B(()=>c(),()=>d()) - Generating delegate wrappers from MethodInfos?

Ultimately, I'm looking forward to a reflection based approach to create a delegate wrapper for a method B(C(),D()) - to some what like (c,d)=>B(()=>c(),()=>d()) First question - Given that you've a Methodinfo, what are the considerations to create a delegate type (via reflection) which corresponds to that method signature? Do you hav...

C# anonymus delegates efficiency/safety

Hello I have progress form which delegate: // in ProgressForm thread public delegate void executeMethod(object parameters); private executeMethod method; public object parameters; // ... private void ProgressForm_Shown(object sender, EventArgs e) { method.Invoke(parameters); } Which way ...

How to I define a delegate type at runtime (i.e. dynamic delegate type)

For creating delegates on the fly, techniques vary from Delegate.CreateDelegate, to Expresion Lambda, DynamicMethod, etc. etc. All of these techniques require that you know the type of the delegate. I'm trying to convert closed delegates to open delegates generically, and to do to achieve this it seems I need to dynamically create the ...

C#: Given src => src.property, code choosing property if you have a string "propertyname"?

I am using AutoMapper where it has: .ForMember( dest => dest.id, opt => opt.MapFrom(src => src.id)) Using the far right expression src => src.id, if I have a string variable with the property's name, how would I choose the property by it? I tried this: src => propertyName Then had to laugh when the value was "id". ...