delegates

What are the advantages of delegates?

What are the benefits/advantages of using delegates? Can anyone provide any simple examples? ...

How to convert a string to a « function signature » to create a delegate?

I'm trying to pass the name of a method from one class to another class, so the other class can "subscribe" her to an event that the first class is not aware of. Let's say I've got those classes: class1 { public void method1(string msg) { //does something with msg } public void i_make_a_class2() { class2 bob = new cla...

How to use custom delegates in Objective-C

I need to know about the usage of delegate methods in objective c... Can anyone point me to the correct source... ...

I have to make a delegate such that when my statusbar gets updated then an event is triggered and the respective text gets displayed.

I have a project in which status bar gets updated many a times. Now i want to create a delegate such that whenever my status bar gets updated then an event is triggered inside the main form class and respective text gets displayed in the status bar, so that i dont have to create a different StatusLabel.Text for everytime my status bar ge...

Determining when IE activex control has been repainted.

I was using spy++ and noticed that the IE control I have embedded in a windows form was periodically calling or sending WM_PAINT when it repaints itself. I'm trying to figure out how in C# code I can perform a C# method every time this control sends WM_PAINT. I know just enough pinvoke at this point to be dangerous. Thanks in advance,...

Synchronising an Asynchronous call in c#

I've run into quite an awkward predicament in a project at work. We need to create users across 4 or 5 different services, and have set it up in such a way that if one fails, they all fail. They're encapsulated within a transaction scope block. One of the services we need to add users to requires telnetting in, and fudging some data. Th...

Error Compiling C++/CLI Delegate call

The following code results in C3867 (...function call missing argument list...) and C3350 (...a delegate constructor expects 2 argument(s)...). What am I doing wrong? public ref class Form1 : public System::Windows::Forms::Form { public: bool IsEven(int i){ return (i % 2) == 0; } Form1(void) { ...

Calling a method group ....

I have a method group that contains elements such as: class Foobar { public static DataSet C(out string SpName) { SpName = "p_C"; return null; } public static DataSet C() { string SpName; C(out SpName); return DataAccess.CallSp( SpName); } } And what I want to do is B...

Is it possible to alias/reference a delegate from a delegate?

Hi, I'm restructuring opur code to use generics. We do use (out of necessity, no changes possible here) own code to attach/detach/iterate/calls delegates. Before there were classes X, Y, Z which declared their own: public delegate void Event_x_Delegate(ref ComParam pVal, out bool result); At the moment I'm passing this delegate to the...

Delegating Control on change of a value/property

Hi all, I'm trying to do something I've been historically available to do using Visual FoxPro (VFP). By use of a "SETALL()" function, I am able to do something like pertaining to a current form... this.SetAll( "someProperty", "toSomeNewValue" ) and it goes through and assigns the value to all controls. By creating my own custom propert...

Delegates used in Threads?

What happen internally when we call BeginInvoke on a variable of delegate type? ...

Using Delegates AND Declaring Events

I'm developing a class library to be used for other developers and will be allowing them to either declare an instance of my class using WithEvents (or similar in other languages) as well as allow them to use Delegates defined in the class. Am I just being redundant here by doing it like this? Public Delegate Sub TimerElapsedDelegate(B...

Use reflection to find the name of a delegate field

Let's say that I have the following delegate: public delegate void Example(); and a class such as the following: public class TestClass { Example FailingTest = () => Assert.Equal(0,1); } How can I use reflection to get the name "FailingTest"? So far I have tried: var possibleFields = typeof(TestClass).GetFields(relevant_bindi...

passing void to a generic class

I'm trying to create a form that will animate something while processing a particular task (passed as a delegate to the constructor). It's working fine, but the problem I'm having is that I can't instantiate a copy of my generic class if the particular method that I want to perform has a return type of void. I understand that this is by...

Are there any build-in cross-thread events in python?

Hello. Is there any build-in syntax in python that allows me to post a message to specific python thread inside my problem? Like 'queued connected signal' in pyQt or ::PostMessage() in Windows. I need this for asynchronous communication between program parts: there is a number of threads that handle network events and they need to post t...

Who adds BeginInvoke, Invoke and EndInvoke method definitions to a typed delegate ?

e.g. if you write... public delegate void MyTypedDel(int x) Intellisense shows that BeginInvoke, Invoke and EndInvoke are part of the MyTypedDel type definition. They are not part of the Delegate or MulticastDelegate type definition. (Delegate has a DynamicInvoke method, which uses late/runtime binding to bind to a method.) So my questi...

What is wrong with this use of Predicate / CreateDelegate?

I'm creating a simple code generator with delegates. Why am I getting this error at runtime: Error while binding the target method. on the following code? XAML: <Window x:Class="Parser.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ...

The purpose of delegates

Duplicate: Difference between events and delegates and its respective applications What are the advantages of delegates? Where do I use delegates? I wonder what the purpose of delegates is. I haven't used them that much and can't really think of something. In my courses, it's written that a delegate is a blue-print for a...

Method parameters seem dynamic, not sure how this works

Hello, If I have a delegate and a method public delegate void SomeDelegate(String p); void aMethod(String p) { } And then I try to invoke this on a new thread like so SomeDelegate sd = new SomeDelegate(aMethod()); sd.BeginInvoke("heyhey", callBack, null) The BeginInvoke method call now accepts a string as the first parameter, how...

Delegates and multicast delegates in VB.NET

What are Delegates and Multicast Delegates in VB.NET? How do I use them? Please provide a simple example to illustrate the concept. ...