delegates

How to create a delegate for a reflected method at run time

I want to create a Delegate of a reflected method, but the Delegate.CreateDelegate requires the Type of delegate be specified. Is it possible to dynamically create a 'Delegate' that matches whatever function is reflected? Here is a simple example: class Functions { public Functions() { } public double GPZeroParam() ...

Asp.net long running process using asynch page

Hi I have a report that takes about 2 or 3 minutes to pull all the data So I am trying to use ASP.net Asynch pages to prevent a timeout. But can't get it to work Here's what I am doing : private delegate List<PublishedPagesDataItem> AsyncReportDataDelegate(); private AsyncReportDataDelegate longRunningMethod; private List<Published...

Delegates and events ?

This question is related to c#.The scenario is that when i click the button the operations like File reading,Data manipulation ,and file dumping are going to be happened.After the completion of each operation i will update the status(i.e,File reading completed,data manipulation completed) in the label which is in UI(FORM-frmTesting) The...

Wheres the best place Iphone app to place a Data Model instance and how would you Access it?

Hey guys! I am learning tons on this thing. Reading also, but this is awesome! Ok.. so long story sort I hope. I'm making a data class to pump out some instances of people that have various attributes. I would like my view controllers to be able to access them (through properties of course.. I think) to manipulate their data. Where in...

pattern for filling uitableview from results of async nsconnection call

Hi, I'm struggling to understand the correct model. I have a uitableview full of rows of data. The data is the result of a REST call, which depends on the result of a previous REST call. So in my appDelegate didFinishLaunchingWithOptions: method I'm making an NSURLConnection for the first REST call and then getting the results back in ...

MethodInfo.Invoke with a delegate inside Object[] params

Let me try to give a little example. class Session ( public delegate string CleanBody(); public static void Execute(string name, string q, CleanBody body) ... can be used like: Session.Execute("foo", "bar", delegate() { string x="beep"; /* whatever*/ return x; }); But what if I need to run is via MethodInfo.Invoke -- as in ...

Does RelayCommand, or passing an Action<T>, behave differently when the method is from an interface?

I think this is my overall .NET inexperience speaking here, but I cannot figure out why this is happening to me. My Model ImportManys an interface called ISystemSetupEditor, and in this case I have a couple of parts that Export that interface. In the application's ViewModel, I have a method that creates a menu, and iterates over the IE...

Func Delegate vs Function

Can someone tell me the advantages of using a delegate as opposed to calling the function itself as shown below (or in other words why choose Option A over Option B)? I was looking at someone's linq code last night and they had something similar to Option A but it was being used to return a compiled linq query. I realize the former can...

Make the App Delegate perform an action?

My AppDelegate_Phone class has the method -(void)doSomething. How can I call that from within a View Controller viewController? I've tried: [[[UIApplication sharedApplication] delegate] doSomething]; No luck. doSomething not found in protocol Edit. The action is being performed, but the Warning persists in XCode. What does the warni...

What is major process of delegates ?

what is main reason for introducing delegates and also it is solution for which type problems.i like to know that problem.Thanks in advance ...

Generic Delegate and IList<T>

Hi, I want to implement a delegate solution for Bubble sort. I have this code: public delegate void SortHandler<T>(IList<T> t); public static void Sort<T>(IList<T> arr, SortHandler<T> func) { func(arr); } int[] arr2 = { 10,1,2,3,4 }; CollectionHelper.Sort<int>(arr2, bubble_sort); bubble sort function signature is: static void bubbl...

How to attach event handler to an event using reflection?

I know about EventInfo.AddEventHandler(...) method which can be used to attach handler to an event. But what should be done if i can not even define proper signature of the event handler, as in, i don't even have reference to the event args expected by the handler? I will explain the problem with the proper code. // Scenario when i hav...

Passing a property into a method to change that property

Not sure if this is possible, but here is what I am trying to do: I want to have a dictionary that contains a mapping of a column index to a property name used to populate that index. In my code I will loop through an array if strings and use the dictionary to look up which column it should map to. My end result code would look like: ...

Serializing Delegates in WCF Using a Surrogate?

I have an idea, but I need help implementing it. WCF does not support delegates in its contracts. Instead it has a cumbersome callback contracts mechanism, and I'm looking for a way to overcome this limitation. I thought about using a IDataContractSurrogate to replace each delegate in the contract with a token that will be serialized t...

sending the delegate methods asynchronously - iPhone

Hi, there! I have defined a protocol like this: @protocol RSSItemParserDelegate <NSObject> - (void)RSSItemParser:(RSSItemParser *)parser didEndParsingSuccesfully:(BOOL)success; @end And I am calling this method when some parsing is finished, on success YES and on failure NO, like this: [delegate RSSItemParser:self didEndProcessSucces...

why do we need delegates

Possible Duplicate: Advantages of using delegates? I know this question has been asked before, but I have one doubt-when we can directly call a method, why we should take help of delegates? can somebody explain with a proper example/reason/scenario EDIT: can somebody explain with a code snippet ...

Sparkle framework delegation question

I have a wrapper application which launches a bundled application and then immediately quits (using [NSApp terminate:nil]). I would like to include Sparkle in this wrapper (it's not going to be possible to include if for the bundled app itself), and I've implemented it without any issues: so long as I comment out the NSApp terminate line...

Executing operations

Which is a better approach to run operations Use Delegate Use Action Use Predicate Use Func Which once is the best in terms of performance, memory and code maintainability. ...

Iphone event delegate

hi... i have drawn rectangle using core Graphics concept now i need to assign some event to this rectangle area how can i do this link button click event thanks in advance ...

What to use instead of initWithStyle: reuseIdentifier:

I have watched the Lynda iPhone tutorials and on the lesson about Tableviews there is a method to create a cell as follows. //create cell UITableViewCell *cell = [[UITableView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentidier:@"cell"]; but Xcode says there is no such me...