delegates Questions
8
Solved
It is not possible to fire an event in C# that has no handlers attached to it. So before each call it is necessary to check if the event is null.
if ( MyEvent != null ) {
MyEvent( param1, param2 ...
1
Solved
My entity class:
class User : ActiveRecord<User>() {
var name by Column(String.javaClass);
var id by Column(Int.javaClass);
}
now I want to set name value by refelection:
var clazz = Us...
Calvo asked 1/6, 2017 at 10:1
1
Solved
In C# I can have references of methods and static methods. Can I also get the reference of a classes constructor?
In Java I can say Supplier<MyClass> createMyClass = MyClass::new (instead of...
Blowtube asked 23/5, 2017 at 6:40
3
Solved
Here is a code excerpt from AspComet project that works with Autofac.
public MessageBus(IClientRepository clientRepository, Func<IMessagesProcessor> messagesProcessorFactoryMethod)
{
this.c...
Balfour asked 8/4, 2010 at 13:40
1
Solved
Does the ?. operator that can be used to invoke a delegate or event avoid race conditions?
Eg. avoid race-condition manually:
//The event-invoking method that derived classes can override.
prote...
Manny asked 5/5, 2017 at 22:41
2
Solved
I have been recently asked in an interview like if we don't have Events and Delegates how can we acheive the same functionality of Publisher and Subsriber model without Delegate and Events.
Can yo...
3
Solved
I've attached delegated event handlers to a number of elements on the page using a single selector. As the events are triggered for individual elements, I'd like to turn off only that element's eve...
Shantay asked 28/5, 2015 at 16:31
1
Solved
I need to create some unit test for delegate/protocol call backs. Here is an example of the implementation I'm trying to test:
protocol SomethingWithNumbersDelegate: class {
func somethingWithDe...
2
Solved
I have an ImagePickerController in my application.
It works well, but beside ipc.delegate = self; there appears an error message:
Assigning to
'id'
from incompatible type 'ViewController *cons...
Empale asked 17/10, 2014 at 13:58
10
Solved
In a Cocoa Touch project, I need a specific class to have not only a single delegate object, but many of them.
It looks like I should create an NSArray for these delegates;
the problem is that NSA...
Tajuanatak asked 14/1, 2011 at 14:37
2
Solved
The function defined in C++ dll is:
static double (*Func1)(double);
EXTERN_C __declspec(dllexport) __stdcall double TestDelegate(double (*fun)(double))
{
Func1 = fun;
return Func1(25.0);
}
voi...
3
Solved
Am studying about delegates. As I read. I learned that adding more than one function in a delegate is called multicast delegate. Based on that I wrote a program. Here two functions (AddNumbers and ...
0
I'm just wondering why delegate in binding iOS project has to use BaseType(typeof(NSObject)) attribute when it's iOS counterpart does not use NSObject
iOS code:
@protocol TestDelegate
- (void)on...
Grenier asked 30/3, 2017 at 19:30
6
Solved
I've been trying to learn about events/delegates, but am confused about the relationship between the two. I know that delegates allow you to invoke different functions without needing to know what ...
Maury asked 15/10, 2009 at 2:13
2
Solved
How to use delegate methods of singleton/shared class?
There is one singleton class having some protocol defined but I'm not getting how to access the delegate functions in other classes.
Code sni...
1
in System.Activities.WorkflowApplication there is a delegate property:
public Action<WorkflowApplicationCompletedEventArgs> Completed { get; set; }
In my program so far, I have a variable...
3
Solved
Consider this MCVE:
using System;
public interface IThing { }
public class Foo : IThing
{
public static Foo Create() => new Foo();
}
public class Bar : IThing
{
public static Bar Create() ...
Paraphernalia asked 16/3, 2017 at 22:33
1
Solved
can somebody explain me the following code please :
this.Invoke((MethodInvoker)delegate
{
lblNCK.Text = cncType;
});
Here is where it comes from :
string cncType;
if (objDMainCncData !...
1
I want a delegate that I can store in a variable for later use that has custom amounts of custom parameters. What I mean by that, is that I want to pus it different methods with different ret...
3
Solved
Using anonymous methods you can create empty delegates since C# 2.0.
public event EventHandler SomeEvent = delegate {};
public event Action OtherEvent = delegate {};
This is e.g. useful to preve...
Atalante asked 22/3, 2012 at 13:40
2
Solved
I've been wondering how delegated properties ("by"-Keyword) work under-the-hood. I get that by contract the delegate (right side of "by") has to implement a get and setValue(...) method, but how ca...
Berkie asked 8/3, 2017 at 10:57
2
Solved
The following code snippet was highlighted in Visual Studio alongside a suggestion for simplifying it.
if ( drawMethodsDelegate != null )
drawMethodsDelegate ( e.Graphics );
When I clicke...
Zetta asked 5/3, 2017 at 11:45
4
Solved
I was trying to understand the evolution of delegates. And how best can this be understood than by understanding what came before it? I understand that the concept of delegates has come from ...
Outturn asked 18/9, 2012 at 11:41
4
Solved
I'm using the mutlipeer connectivity framework for the first time, and I want programmatic ( not with the assistant classes) control.
Everything is working exactly as described when I run my code ...
Ailey asked 21/1, 2014 at 16:54
2
Solved
In one of my classes I use an array of delegates (the class is a singleton). This is causing an retain cycle. I know I can avoid the retain cycle when I use only one delegate by making the de...
Gauthier asked 25/2, 2017 at 14:53
© 2022 - 2024 — McMap. All rights reserved.