delegates Questions

3

Solved

I need a method that takes a MethodInfo instance representing a non-generic static method with arbitrary signature and returns a delegate bound to that method that could later be invoked using Dele...
Vicious asked 3/5, 2013 at 17:4

5

Solved

I have a bunch of functions in Python out1, out2, out3 etc. and would like to call them based on an integer I pass in. def arryofPointersToFns (value): #call outn where n = value Is there an e...
Charbonnier asked 18/4, 2011 at 19:4

3

Solved

Rather perplexed by this omission--but in Qt's QAbstractItemView class, it's possible to set a QAbstractItemDelegate (i.e., QItemDelegate or QStyledItemDelegate) to the entire view, a single row, o...
Evolve asked 15/3, 2013 at 20:59

3

Solved

I have a drop down list that is populated by inspecting a class's methods and including those that match a specific signature. The problem is in taking the selected item from the list and getting t...
Calabar asked 2/6, 2009 at 16:58

2

Solved

I want to use Kotlin delegation in a particular context. The delegate should not be passed in the constructor. I want to keep a reference to the delegate for later use in the code. From within the...
Meijer asked 21/4, 2022 at 13:18

4

Solved

This is related to the question about return type attributes and anonymous classes, but then for anonymous methods (or lambdas), but as far I could find this exact question does not seem to be on s...
Cromorne asked 15/9, 2009 at 12:19

3

Solved

I'm building a hierarchical collection class that orders magnetic resonance images spatially and arranges them into groupings based on the various acquisition parameters that were used to generate ...
Ximenez asked 4/3, 2011 at 19:59

12

Solved

I understand lambdas and the Func and Action delegates. But expressions stump me. In what circumstances would you use an Expression<Func<T>> rather than a plain old Func<T>?
Pitch asked 27/4, 2009 at 13:50

14

Solved

Is it possible to unsubscribe an anonymous method from an event? If I subscribe to an event like this: void MyMethod() { Console.WriteLine("I did it!"); } MyEvent += MyMethod; I can un-subscr...
Magnanimity asked 8/10, 2008 at 15:24

4

Solved

Is it possible implement the GOF command pattern using a Queue of Action delegates? I have been trying to wrap my head around it for a while and I am stumped because each of the possible actions I...
Decameter asked 11/10, 2010 at 5:44

5

Solved

If I have the below code, should I just call the Action or should it call Action.Invoke? public class ClassA { public event Action<string> OnAdd; private void SomethingHappened() { if (...
Shears asked 13/2, 2012 at 11:11

4

Solved

I want to do a lazy initialization for a var property. Since by lazy is restricted only to val properties I have to write something like this: private var currentContextProvider: ContextProvider?...
Roselleroselyn asked 22/12, 2017 at 21:59

9

Solved

Take the method System.Windows.Forms.Control.Invoke(Delegate method) Why does this give a compile time error: string str = "woop"; Invoke(() => this.Text = str); // Error: Cannot convert lambd...
Xylia asked 4/1, 2009 at 20:0

13

Solved

I have several methods all with the same parameter types and return values but different names and blocks. I want to pass the name of the method to run to another method that will invoke the passed...
Luttrell asked 17/1, 2010 at 21:1

15

Solved

How does one go about making a delegate, i.e. NSUserNotificationCenterDelegate in swift?
Abruzzi asked 7/6, 2014 at 16:23

9

Solved

Say I have a class with many of public methods: public class MyClass { public void method1() {} public void method2() {} (...) public void methodN() {} } Now I would like to create a wrapp...
Carpometacarpus asked 20/5, 2015 at 8:50

10

Solved

Can someone provide a good explanation (hopefully with examples) of these 3 most important delegates: Predicate Action Func
Wellknown asked 19/2, 2009 at 19:49

6

Solved

I would like to pose this question as long as I am trying currently to dig into the use and the purpose of delegates, although it is likely to have been asked in similar formulations. I know that ...
Hepatitis asked 1/1, 2012 at 19:17

5

I was investigating the performance hit of creating Cachedependency objects, so I wrote a very simple test program as follows: using System; using System.Collections.Generic; using System.Diagnosti...
Cimon asked 15/3, 2010 at 14:57

2

Solved

I'm working on a Windows Forms application, and it contains custom controls with methods that can potentially be called from threads other than the UI thread. So these methods therefore look a bit ...
Razorback asked 17/7, 2015 at 10:34

4

Solved

I've recently moved back to C# from being in Objective-C land, and the async/await keywords in C# 5 look cool. But I'm still trying to get a handle on the proper syntax. I want to declare a method...
Rutaceous asked 14/12, 2011 at 20:51

1

Solved

I am converting an iOS app from UIKit to SwiftUI. I have a UIViewController that displays a view with different buttons. This UIViewController has a delegate that conforms to a specific proto...
Weinstein asked 3/12, 2021 at 19:31

2

Solved

didOutputSampleBuffer function in my code was not called. I don't know why it happened. Here's the code: import UIKit import AVFoundation import Accelerate class ViewController: UIViewController ...
Miculek asked 3/1, 2016 at 2:57

6

C# delegates have always been difficult for me to grasp and so I was very happy to stumble across logicchild's article on The Code Project web site titled "C# Delegates: Step by Step". He has a ver...
Denysedenzil asked 20/9, 2010 at 11:9

6

Solved

Suppose I have two applications written in C#. The first is a third party application that raises an event called "OnEmailSent". The second is a custom app that I've written that I would like to s...
Siloa asked 20/8, 2008 at 13:1

© 2022 - 2024 — McMap. All rights reserved.