C# stop waiting on events

Started by
4 comments, last by DvDmanDT 11 years, 10 months ago
Im using C# to start on a Particle Editor for school, but I forgot how to stop waiting on events.

I know you at least need to do this, which i've done, but i can't remember what else I was supposed to do somewhere else. Anyone else know?

// Inherit from Panel
class graphics_panel : Panel
{
public graphics_panel()
{
DoubleBuffered = true;
}
}
Advertisement

Im using C# to start on a Particle Editor for school, but I forgot how to stop waiting on events.

I know you at least need to do this, which i've done, but i can't remember what else I was supposed to do somewhere else. Anyone else know?

// Inherit from Panel
class graphics_panel : Panel
{
public graphics_panel()
{
DoubleBuffered = true;
}
}


Check the value of DoubleBuffered, and if it's true, start the relevant code, is what comes to mind.
well by default c# waits on an event to happen like "GetMessage()" in Windows. I want it to run like "PeekMessage". I just don't remember where to change that, i know it wasn't that buffer check though. Thanks anyways =)

well by default c# waits on an event to happen like "GetMessage()" in Windows. I want it to run like "PeekMessage". I just don't remember where to change that, i know it wasn't that buffer check though. Thanks anyways =)

Ah - You're probably looking for an EventHandler, then.
I believe what you are looking to do is discussed here: http://blogs.msdn.com/b/shawnhar/archive/2010/12/06/when-winforms-met-game-loop.aspx

It's targeted for XNA + Winforms, but should be applicable in straight Winforms applications that need animation timing as well.
There are several ways to do what you want. In order to not wait for messages at all, you must change Application.Run(new YourForm()); in Program.cs (default location of that line). An easier solution would be to just add a timer and call Refresh() or yourPanel.Refresh() on its Tick event.

This topic is closed to new replies.

Advertisement