Hey guys,
I need to display some stats, numbers, and graphs about various game objects on the screen.
(examples: camera position, field of view, frames per second, fill rate, number of objects culled, etc... )
Currently any object which wants to be graphed or displayed implements an interface along these lines:
public interface IGra...
I took the following example from Jrista's answer to a post.
Finding Twentyone count
int[] numbers = new[] { 1, 3, 11, 21, 9, 23, 7, 4, 18, 7, 7, 3, 21 };
var twentyoneCount = numbers.Where(n => n == 21).Count();
Suppose i use "Func" delegate how can i get the count ?
I tried as (pardon me for the bad syntax)
var otherway= F...
Hey,
I have a function that receives two parameters - an object, and an EventInfo structure defining an event on that object. I need to block that function until the specified event fires. The problem I have is, how do I add a delegate to the specified event, when the type of handler could be anything? Note that I don't care about the ...
It appears that VB in VS8 doesn't support/convert lambda expressions with a statement body. I'm using them in my C# application, but now must convert it to VB.
I'm creating a whole bunch of controls dynamically, and I want to be able to give them event handlers on the fly. This is so I can build a dynamic user interface from a databas...
Introduction
I am trying to use P/Invoke to register a struct of callbacks with a native dll. When calling a function that makes the native dll invoke the callbacks an AccessViolationException occurs. I have constructed a "small" test case that demonstrates the behavior comprised of 2 files, native.cpp that compiles into native.dll and ...
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 particular function is being invoked. (eg: a graphing function needs to accept inputs that are different functions to be graphed).
But I don...
Is there a simple way to print the code of a delegate at runtime ? (that "contains one method").
public delegate void SimpleDelegate();
SimpleDelegate delegateInstance =
delegate { DoSomeStuff(); int i = DoOtherStuff() };
Now, I would like to display on the screen the body of delegateInstance. That is to say, doing someth...
Is there any way to get consistent results from Comparison when some of the sort items are the same? Do I just have to code up my own sort routine?
public class Sorter
{
public void SortIt()
{
var myData = new List<SortData>(3);
myData.Add(new SortData { SortBy = 1, Data = "D1"});
myData.Add(new So...
The following example works, but how can I change it so that instead of executing the anonymous method, it executes my existing callback method OnCreateOfferComplete()?
using System;
namespace TestCallBack89393
{
class Program
{
static void Main(string[] args)
{
OfferManager offerManager = new OfferM...
This question is being asked because I have no prior experience with delegate best practices
I have a unordered lists in html, where the structure is the same throughout my site, but the content of the lists may differ.
Examples:
List of object A
<ul>
<li>
<ul>
<li>A.someMember1</li>
<li>A.someMember2</li>
<li>...
Given the code below:
void LookupBox_Load(object sender, EventArgs e)
{
Action d = delegate
{
if (!_p.AutoClose)
CloseLookupBox();
};
if (this.ParentForm.MdiParent != null)
this.ParentForm.MdiParent.Deactivate += delegate { d(); };
else
this.ParentForm.Deactivate +...
When i want to use delegate class to make call while windows form working, i always have to use InvokeRequired. It is ok. But who changed the InvokeReuqired property while it is working.
Please check this image:
...
I'm currently building a node editor (as in Blender) and am having trouble getting delegates to property accessors from a generic type. So far the question here has brought me closest, but I'm having trouble that I think is specifically related to the type of object being generic.
For reference, a "Node" is synonymous with an object, an...
I'm working on a game for the xbox360, using XNA. On the Xbox the garbage collector performs rather badly compared to the one on a PC, so keeping garbage generated to a minimum is vital for a smoothly performing game.
I remember reading once that calling a delegate creates garbage, but now for the life of me can't find any references to...
I have a progress bar on a UI I would like to update when a record gets inserted into my database. I have done this before when I only had a UI Tier and a Business Tier with no problems. But I am now breaking my code into a UI Tier, Business Tier, and Data Tier and I can't figure how to properly call my OnPropertyChangedEvent in my Dat...
Hello,
I am currently implementing a timer/callback system using Don Clugston's fastdelegates. (see http://www.codeproject.com/KB/cpp/FastDelegate.aspx)
Here is the starting code:
struct TimerContext
{
};
void free_func( TimerContext* )
{
}
struct Foo
{
void member_func( TimerContext* )
{
}
};
Foo f;
MulticastDelegate< ...
Based on my understanding , i interpret the meaning of Func delegate as follows.Please correct them as and when it is needed.
Declaration : Func<int> dg ;
1. Could i interpret it as "a Delegate
pointing to a method that returns an
integer?".
Declaration : Func<int,int> delg1=r=>2*r;
*2. Could i interpret it as " 'r' is a la...
The problem:
a .Net 2.0 class with a few thousand delegate fields generated by a code generator
varying signatures
delegates may or may not return values
no generics
these delegates much be initialized quickly at runtime
initializing a delegate is simple but expensive
initializing the whole lot costs ~300ms right now - acceptable,...
Suppose the following code:
foreach(Item i on ItemCollection)
{
Something s = new Something();
s.EventX += delegate { ProcessItem(i); };
SomethingCollection.Add(s);
}
Of course, this is wrong because all the delegates points to the same Item. The alternative is:
foreach(Item i on ItemCollection)
{
Item tmpItem = i;
Som...
I have a class like below:
class Foo
{
public Foo(int x) { ... }
}
and I need to pass to a certain method a delegate like this:
delegate Foo FooGenerator(int x);
Is it possible to pass the constructor directly as a FooGenerator value, without having to type:
delegate(int x) { return new Foo(x); }
?
EDIT: For my personal use, ...