Monday, July 12, 2010

WPF Simple Puzzle

Hi, recently i publish an article about a simple puzzle application made with WPF-C#. Here to get there. Good luck everybody.

Wednesday, June 30, 2010

What's Behind Event Raising?



Assalamualaikum,
Hello everybody


In this post I want to tell you about my confusion in event raising in .NET family language (I use C#). In most tutorial you may see this kind of way to raise event (this one is from msdn, but I changed the class name) :




public class ArrayListWithChangedEvent : ArrayList
{

public event EventHandler Changed;

protected virtual void OnChanged(EventArgs e)
{
if (Changed != null)
{
Changed(this, e);
}
}



This one will be the method which call the method raising the event, it calls OnChanged (Please correct any of my misunderstanding :D ).




public override int Add(object value)
{
int i = base.Add(value);

OnChanged(EventArgs.Empty);

return i;
}



In the class which use an object of ArrayListWithChangedEvent , the method which handle the event is




void list_Changed(object sender, EventArgs e)
{
Console.WriteLine("This is called when event fires");
}



All right. What I am confused in is, sometimes or very often, we use buttons in our application, then, how to raise the Click event of the button? Does it checks every milliseconds if a button clicked (do polling) then they call the method Clicked(this, e), or it uses interrupt? If it uses interrupt, does somebody now how to use such an interrupt in C#? Hey. It will be very efficient if we can use such interrupt in our application than we have to do polling like in XNA, for example




KeyboardState currentState = KeyboardState.GetState();
If(currentState.IsKeyDown(Keys.A))
{




Right???




Correction and answer is really appreciated. Thank you very much.

Tuesday, June 29, 2010

First Post

Assalamualaikum

Good morning in cyber world :)

This is my first post in this blog. Let me introduce myself. I'm Nanung, I'm from Indonesia, and I'm a newbie in this blogging world.

I hope this kind of activity will be nice.

Thanks.