delegates

Delegate fields related with events & Reflection

Hi again, now i have a more theorical question related with events and reflection. The question is: "Is or isn't possible to get the field of type delegate associated with an event via EventInfo?" Basically when you define an event (implicitly), the compiler adds a private delegate field to your class (the delegate is of the same type o...

Performance of calling delegates vs methods

Following this question - http://stackoverflow.com/questions/2082615/pass-method-as-parameter-using-c and some of my personal experience I'd like to know a little more about the performance of calling a delegate vs just calling a method in C#. Although delegates are extremely convenient, I had an app that did lots of callbacks via deleg...

delegates in C#

i have 3 files that i need to compare to 100 other files (by using some functions i wrote). i take each file from the three and in loop compare them to each one of the 100 files. i want to use the functions sequentially, after i finish to compare the 3 files to the 100 files i want to activate the next function, how can i do it ( the sig...

How to manage 2 tableviews in 1 viewController?

Hi. Does anyone know a simple way to manage several tableViews in one viewController? Here is how I've been doing it so far: -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if(tableView == self.tableView1) return 1; else if(tableView == self.tableView2) return 2; } -(NSString *)tableView:(UITableView *)tableView t...

Can a delegate carry parameters?

Hi. Let's say I have a function public void SendMessage(Message message) { // perform send message action } Can I create a delegate for this kind of function? If so, how can I pass a message when I use the delegate? In my case, the function is used by Thread. Whenever there is an event, I need to send a message to the server, to k...

UIPickerView with 2 NSMutableArrays?

I have a core data based app I am working on, that uses an EditingViewController to control a number of different UI elements that get input from the user which describe attributes of an object that is subsequently stored within my app. The EditingViewController.xib file has such elements as a datePicker, textField, numberSlider, and whe...

(How) is it possible to bind/rebind a method to work with a delegate of a different signature?

I'm a c++ developer having used signals & slots in c++ which to me seems to be analogous to delegates in c#. I've found myself at a loss in searching for the functionality provided by "bind", and feel I must be missing something. I feel like that something like the following, which is possible in c++ should be possible in c# with delega...

Asp.Net - Can the absolute expiry for a Cache with CacheUpdateCallback be smaller than 20 seconds?

I have the a test harness detailed below. This has two labels on the page that are set within the page_load which is hit every second due to the updatepanel and timer. Label1 is set to a datetime value that is stored in the Cache. Label2 is set to the current datetime. The cache is set with an absolute expiry of 5 seconds from now and ...

Replacing parameters in a lambda expression

I had a part of code that takes in lambda expressions at runtime, which I can then compile and invoke. Something thing; Expression<Action<Something>> expression = (c => c.DoWork()); Delegate del = expression.Compile(); del.DynamicInvoke(thing); In order to save execution time, I stored those compiled delegates in a cache, a Dictionar...

Remove delegate on dealloc from unreferenced object

If learned the hard way that you should remove the delegate from an object if the life span of the delegate is shorter than the object. But how do you do this if you don't have a reference to the object anymore? In my iPhone application I have a view controller vc which performs an asynchronous activity and is displayed as a modal view....

Delegate variables not garbage collected

Recently discovered that the variables inside ToGadget, and presumably the delegate as well, weren't getting garbage collected. Can anyone see why .NET holds a reference to this? Seems that the delegate and all would be marked for garbage collection after Foo ends. Literally saw *B*illions in memory after dumping the heap. Note: 'res...

Providing parameter names for delegate types

Is it possible to specify parameter names for delegate types in F#? When I create a delegate of this type in F#: type DataValidationEventHandler = delegate of obj * DataValidationEventArgs -> unit ...it auto-generates this signature for the handler in C#: static void loader_ValidationEvent(object __p1, DataValidationEventArgs __p2) ...

What makes FSharpFunc<> faster than Func<> ?

I'm curious about the performance enhancements that have been made for FastFunc<>. Is it the fact that it does not contain multiple delegate so there is no need to loop over all the references when firing a function call ? Anything else ? ...

Creating an object to act as a delegate - Objective C

My question is simple actually, how do I create an object to act as a delegate, instead of including the delegate methods in my view? For example, I have x functionality that requires delegate methods, and they're currently setup to use self as the delegate. I'd like to put those methods in their own object so that the delegate methods ...

C# Invoke Action Cross Thread Access

greetings, im new to programming. at the moment my application uses delegates to process/execute methods that reside in a another class/object. but i was getting an error stating that they were residing in separte threads. so after searching the web i came up with this: this.Invoke(new Action(delegate() { this.ChatRichTextBox.AppendT...

Unfamiliar with technique to solve pre-populating textfields (w/out access to a viewDidLoad or similar method) on Mac Desktop

Hey, I have a mainMenu.xib - that sets up all my interface items (button, textfields, etc). I have a LogController that has access to all these items via IBOutlet and IBAction. Works fine - All connected and running well. However, I want to have NSUserDefault values pre-populated in the textfields. However, I can't figure out how - si...

[C#] Heterogenic list of delegates

Hello, Is it possible to create a list containing delegates of different types ? For example considere this two delegates : class MyEventArg1 : EventArgs {} class MyEventArg2 : EventArgs {} EventHandler<MyEventArgs1> handler1; EventHandler<MyEventArgs2> handler2; I would like to do something like that : List<EventHandler<EventArgs...

UITextField, automatically move to next after 1 character

Scenario: I have 4 UITextFields that only accept 1 character. Easy. Problem: After I enter the 1 character, I want the next TextField to become active automatically without having to press next (i.e. I'm using the UIKeyboardTypeNumberPad, and theres no NEXT button. (I KNOW I can actually create a next button programmatically, but I dont...

AddHandler only if no handlers for this event?

I want to set an event handler only if this is not set: If GetHandlers(MyWindow.Closed, AddressOf MyWindow_Closed).Length = 0 Then AddHandler MyWindow.Closed, AddressOf MyWindow_Closed EndIf ...

How do you remove one-time-use class variables from Objective-C code?

I'm writing some Objective-C code and I've frequently hit the situation where I have to use a class variable to store a value for one time use. After consuming it I no longer need it. To me, storing this value in a class variable seems like code smell. Really the value should be passed in as a parameter to the methods I'm using. I ru...