I have many textfield, that only support using type "A"/"B"/"C" only, I wrote a textfield delegate to check the user input, including the length and the content that they inputed. But I want to separate the delegate from the class file. How can I do so? Thank you.
...
I need to add some methods to the delegate protocol of my custom UITextField subclass. So I put this in the header:
@protocol MyTextFieldDelegate (UITextFieldDelegate)
- (void)textfieldDidSomething:(UITextField*)textField;
@end
Is this fine?
...
Hi,
Can somebody explain what is the exact reason behind using Action<T> and Predicate<T> as delegates in C#
...
I have two threads main thread and worker thread. What I want to be able to do is schedule callbacks (delegates) to the worker thread irrespective of who calls functions that trigger those delegates. For example:
/* mainThread */
[Obj asyncCallback]; // triggers callback to delegate foo()
/* Worker thread should do all the callback pro...
Hi all,
I have a few methods like this
public void DoSomething(Action<int> action) { ... }
In some cases I do not use the parameters passed into action. Are there any differences I should be aware of between calling it like this
DoSomething(delegate { ... });
or
DoSomething(_ => { ... });
...
I have
public delegate void DocumentCompleteEventHandler(object pDisp, ref object URL)
Can i use lambda expression such as :
ie.DocumentComplete += (o, e) => { };
It expression doesn't work. How should i change it for using in code? Is it possible?
...
How can I store delegates (named, anonymous, lambda) in a generic list? Basically I am trying to build a delegate dictionary from where I can access a stored delegate using a key and execute it and return the value on demand. Is it possible to do in C# 4? Any idea to accomplish it?
Note : Heterogeneous list is preferable where I can stor...
Could someone explain the meaning of the following portion of code :
private event UserChangedHandler m_UserChanged;
public event UserChangedHandler UserChanged
{
add
{
if (m_UserChanged != value)
{
m_UserChanged += value;
}
}
}
thanks
...
I've got a problem with my test code. It compiles well, but when I try to call delegate, program crashes.
#include "..\libs\FastDelegate\FastDelegate.h"
#include <string>
#include <map>
#include <iostream>
typedef fastdelegate::FastDelegate1 <int, int> FuncPtr;
struct Function
{
FuncPtr Ptr;
int Param;
Function() {};
Function (Fun...
I'm studying delegates and simple threading, I tried it in a ComboBox control, and experimented in a DataGridViewComboBoxColumn (cause I thought it would be the same) but it seems there's no Invoke property for this kind.
How can I set DataGridViewComboBoxColumn properties in a thread?
Please see my code, this works for setting the prop...
I've noticed some examples of things that work and don't work when dealing with lambda functions and anonymous delegates in C#. What's going on here?
class Test : Control {
void testInvoke() {
// The best overloaded method match for 'Invoke' has some invalid arguments
Invoke(doSomething);
// Cannot convert ...
Style question.
The C# 1.0 way to subscribe to an event is to use an explicit encapsulating delegate:
publisher.RaiseCustomEvent += new CustomEventHandler(HandleCustomEvent);
In C# 2.0 they added a simpler syntax:
publisher.RaiseCustomEvent += HandleCustomEvent;
In Visual Studio 2010 (tested with a .NET 3.5 project) typing
"my...
Hi
I'm having a little problem. I subclass'd UIAlertView and I named it UIDisclaimerAlertView.
So far so good, the subclass is working fine. But now I wanted to use this very class as its own delegate. So in my subclass I used : self.delegate = self; I did this because I wanted it all in the same class file.
Now the problem I'm facing...
Hello,
I am new to event and delegates. Could you point me to the right direction for implementing Enqueued event for an object of type Queue<T>?
I am using C# and .Net 4.0
Thanks
...
I am having some problems implementing QuickLook functionality from a table in an NSView. The limited documentation on QuickLook really doesn't help at all.
After reading through the Apple Docs (which are geared heavily towards custom generators and plugins), I ended up looking at the QuickLookDownloader sample code. This code is based ...
Hi! Can you please help me here, why the compiler does not infer the lambda input parameter right?
Example:
void Test(Action<string> n)
{
}
void Test(Action<int,string> n)
{
}
Ok so when doing this:
obj.Test(x=>{}); // compiler doesn't know x is a string
If I do this:
obj.Test((x,y)=>{}); // that works, compiler know x is a int ...
Hey!
In IronPython I am trying to call a PythonFunction with different numbers of arguments from C#. For instance;
I want to do:
def foo(a, b):
print a, b
def bar(a, b, c = None):
print a, b, c
p = App.DynamicEvent()
p.addHandler(foo)
p.addHandler(bar)
p.invoke("Not", "Working")
where addHandler takes a single argument ...
We were having a discussion at the office on how to solve a particular problem and using an event was raised (no pun intended). The response was negative citing misuse and that they can be expensive.
I understand the concerns behind misuse and I know that they are just a special multicast delegate but given a scenario where there is at ...
Hi, This is my first time using delegate in c# application. can some one check if i use this correctly.
int totalsales = 0;
adddata(){
........
BeginInvoke(new UpdateSalesDelegate(UpdateSales), numbersale);
}
private delegate void UpdateSalesDelegate(int args);
private void UpdateSales(int args){
totalsales = totalsales + args;...
I'm curious if it's possible to create a delegate method with implicitly typed arguments. Here's what I'm trying to accomplish. This sort of thing won't compile for me, but it should give you an idea of what I'm trying to accomplish.
here's the functions I want to call using delegates:
class MyClass
{
ArrayList function1(int param1...