Dynamic AddressOf
What is the best way of referencing a dynamic delegate. I'd like to do the following with method names returned from a configuration database. AddressOf "MethodName" ...
What is the best way of referencing a dynamic delegate. I'd like to do the following with method names returned from a configuration database. AddressOf "MethodName" ...
I have come across what must be a common problem. When I have an event which may be subscribed to by several different classes, an exception thrown by one of these classes will kill the callback chain; as I do not know a priori in what order the callback is carried out, this can result in unpredictable state changes for some classes and ...
Hi, I'm designing an application that supports plugin development. Its more of a learning exercise. I've come across a problem I don't know how to solve. All of the assemblies (plugins) being loaded into my app contain a showPrefs() method. As I load each assembly, I want to assign a button to each one so that when I click on the butt...
I'm hoping to clear some things up with anonymous delegates and lambda expressions being used to create a method for event handlers in C#; for myself at least. Suppose we have an event that adds either an anonymous delegate or lambda expression [for you lucky crowds that can use newer versions of .NET]. SomeClass.SomeEvent += delegate...
As a fairly junior developer, I'm running into a problem that highlights my lack of experience and the holes in my knowledge. Please excuse me if the preamble here is too long. I find myself on a project that involves my needing to learn a number of new (to me) technologies, including LINQ (to OBJECTS and to XML for purposes of this pr...
Hi! Just want to know what's the common way to react on events in python. There are several ways in other languages like callback functions, delegates, listener-structures and so on. Is there a common way? Which default language concepts or additional modules are there and which can you recommend? ...
I have this method: private delegate void watcherReader(StreamReader sr); private void watchProc(StreamReader sr) { while (true) { string line = sr.ReadLine(); while (line != null) { if (stop) { return; } //Console.WriteLine(line)...
This was mentioned in my other question and I thought it might be useful to add it to the record. In the following program, which, if any, of the locally defined delegates are cached between calls to the Work method instead of being created from scratch each time? namespace Example { class Dummy { public int age; } ...
I am building a class that handles NSURLConnection requests. To allow other classes to use this class, I would like to allow the main class to call a delegate when connectionDidFinishLoading is fired. I've looked through lots of documentation, but I can't find anything that gives any clear examples, and the code that I have doesn't cal...
I'm creating a simple project for iPhone, using XCode and Interface Builder. While I understand what a delegate is, I have a problem with using it. I have an UITextField in my interface. It displays keyboard when user taps on it, but I need to program manually how to hide keyboard. It can be done using delegates. So in IB, I'm taking Ob...
Does anyone know a good (free) C# eBook for Intermediate programmers? I want something that covers generics, threads, events, delegates, etc. See also: http://stackoverflow.com/questions/391523/what-are-some-good-free-programming-books#392926 ...
The .NET framework provides a few handy general-use delegates for common tasks, such as Predicate<T> and EventHandler<T>. Is there a built-in delegate for the equivalent of CompareTo()? The signature might be something like this: delegate int Comparison<T>(T x, T y); This is to implement sorting in such a way that I can provide a la...
What is a good delegates tutorial for C#? ...
I'm looking for the shortest code to create methods to perform common operations on items in an IEnumerable. For example: public interface IPupil { string Name { get; set; } int Age { get; set; } } Summing a property - e.g. IPupil.Age in IEnumerable<IPupil> Averaging a property - e.g. IPupil.Age in IEnumerable<IPupil> Buildi...
So i have a design problem. I have a mouse class that has delegates and events. ie MouseButtonPressed, MouseMoved. and such that are getting called by a state engine. What i want to have happen is to create an interface like IClickable or IDraggable or somthing and have events inside those interfaces that get called when the mouse even...
Anyone know how to automatically create a delegate stub method? In WPF it seems im constantly having to pass delegates around. i would like to be able to type a method name that doesnt exist and have a method stub automatically generated...currently i'am having to constantly reference the docs to get the delegate signature and then manu...
What's a jQuery like and/or best practices way of getting the original target of an event in jQuery (or in browser javascript in general). I've been using something like this $('body').bind('click', function(e){ //depending on the browser, either srcElement or //originalTarget will be populated with the first //element that in...
Lets say I have a component called Tasking (that I cannot modify) which exposes a method “DoTask” that does some possibly lengthy calculations and returns the result in via an event TaskCompleted. Normally this is called in a windows form that the user closes after she gets the results. In my particular scenario I need to associate so...
Can I dynamically create a function and invoke it (passing values into it) in one line of code? Clarification: I was looking for some way that could allow me to create an anonymous function and then calling it directly. Sort of: delegate(string aa){ MessageBox.show(aa); }("Hello World!"); or something like that (I know the above code...
I think I understand the concept of a delegate in C# as a pointer to a method, but I cant find any good examples of where it would be a good idea to use them. What are some examples that are either significantly more elegant/better with delegates or cant be solved using other methods? ...