Delegates can refer to several concepts. An object can rely on another (a delegate) to perform a function. Delegation can also refer to programming language feature making use of the method lookup rules for dispatching self-calls. In C#, a delegate defines which method to call when an event is ...

learn more… | top users | synonyms

2
votes
1answer
37 views

Delegate and Observer pattern implementation for an embedded system

I'm writing a set of simple widgets for a microcontroller application. I'd like to use the observer pattern to pass around events: when a button is clicked, when a timeout occurs - there are many uses ...
0
votes
1answer
60 views

How could this C# delegate call become shorter? [closed]

Func<string, string> DoSomething = delegate(string something) { return DoTheRealThing(something); }; DoTheThingWith(DoSomething); I want to do it one ...
7
votes
2answers
156 views

Game passive skill system

I'm trying to create some easily accessible database of different skills. General idea is that every skill should do something different and be able to act on different things (ex. one skill which ...
2
votes
1answer
77 views

Delegate that selects a writable property on a generic

In the following contrived example, I have a collection of PropertyManagers that each contains selector and assigner delegates to read from and write to a property ...
3
votes
2answers
78 views

follow-up review of a custom Undo Manager

This is a follow up review of question 'a custom Undo Manager'. After reviewing all the comments and answers, my code has been revised (completely rewritten) based on the review. Summary The ...
7
votes
3answers
241 views

A custom Undo Manager

I am working on building an UndoManager in C#. The concept is to store events and property changes in a ...
2
votes
1answer
245 views

C++ delegate implementation with member functions

I have been implementing a delegate class with C++11 that supports class member functions. I am interested in knowing if there are any potential problems with this implementation. My main concern is ...
1
vote
2answers
126 views

Improving this implementation of delegates

I borrowed the code from this question. I'm trying to implement the delegate in that code. Below is my outcome so far. What else can be done to improve this code? Any suggestions? I would appreciate ...
1
vote
2answers
93 views

Refactoring Into Generic Methods

This might be a loaded question, but here goes. I have some code that is very similar between all the methods. I am trying to find a way to accomplish all methods with a generic method/function. I'm ...
1
vote
2answers
852 views

Designing an EventHandler in C++

I am writing a simple event handling class in C++, to avoid having delegate registration and calls cluttering the rest of the code. I have a design that seems to do the job, but it has a couple of ...
4
votes
1answer
144 views

State Machine for Character

I come today with a state machine I'm currently working on. Problem: Given any State that the Character is in, a button press or combination of button presses can modify that state in a different ...
5
votes
1answer
512 views

Generic method for database calls

Background Breaking from MVC, I've implemented the following architecture: POST/GET ➤ PHP ➤ Database Calls ➤ XML ➤ XSLT ➤ HTML All database interactions are ...
1
vote
1answer
83 views

Refactoring Java transmitter delegate implementation

I have 3 classes: a transmitter, a view for displaying and a recording view for flushing the screen contents into a file. The view and the recording view classes register themselves from their ...
1
vote
1answer
266 views

Possible memory-leak on a self-removable event handler

A friend of mine asked me a question recently. He was needed to subscribe to an event of some object (window button click) and unsubscribe from it on a first call of a handler. Also he noticed that ...
1
vote
1answer
646 views

Using delegates to communicate between forms and networkcommunicator class

I'm trying to develop an application in c# i currently have a code similar to the one attached below. Basically what it does is: Having multiple form, each of which would like to send message through ...
2
votes
1answer
355 views

Putting called delegate into AsyncState parameter - Pros/cons?

I have the following interface: ...
5
votes
2answers
610 views

Generic Wrapper for a Task-based API

I've written a piece of an ugly code. The idea was to provide a clear-looking, type-inferring framework to test a task-based API (it's for integration testing, and test methods should be as clear as ...
2
votes
1answer
169 views

Delegate for GUI project

I wrote simple delegate in C++11 for my GUI project. I think that some parts can be optimized or cleaned. ...
8
votes
1answer
422 views

using <T> in generic delegates?

Here is my problem. Do I need to give a new identifier to each delegate I write of the following delegate type? like so: or could i use one delegate that accounts for any Datatype I need to use so i ...
4
votes
2answers
182 views

How to simplify these delegate functions?

I'm looking for a way to simplify this code, because I could develop more overloads for TryThis I made the string and int both of class ...
3
votes
1answer
280 views

Cancelable thread worker

My goal was to create class, that can run external method in non blocking manner. Second requirement was to be able to abort method run if it is needed (i.e. running user script). I decided to do that ...
2
votes
1answer
143 views

Is it correct to use delegates as properties?

I need to create a class with two properties: LogOutput ExceptionOutput These properties (of type ...
2
votes
1answer
3k views

Polling loop to run in a background thread

I came up with the idea of a small utility class that will poll some delegate until the response received meets some condition, upon which it will notify the main thread which can take the appropriate ...
4
votes
1answer
662 views

WeakAction Implementation

Here's my first attempt at creating a WeakAction using Expressions and Delegates. I would like it to be clear that this code was written after reading serveral blogs and taking snippets from various ...
4
votes
4answers
867 views

Thread-safety and delegates with generated numbers

In the main class, loops generate numbers (0~100), and when its generated number is > 20, its value is passed to the thread where it simulates some work with this number. Meanwhile, while this number ...
4
votes
3answers
523 views

Improve my Task Loops

How can I improve up this code? Is it ok to write code using Invoke and Action so liberally or is this bad? Performance is not ...
2
votes
1answer
290 views

Anything I'm missing on this delegate implementation?

Just as the question states and to be sure, am I missing anything on this? Something important/obvious that I overlooked? As is, I can save any functor, function pointer and member function pointer ...