Sunday, September 13, 2009

WPF: rendering & timer

strange that there's a 24fps limit even on DispatcherTimer

have to use a thread to force a fast refresh rate

partial code:

bool running = true;
public delegate void updateDelegate();


public Window1(){
Thread t = new Thread(new ThreadStart(Run));
t.Start();
}

void Run()
{
while (running)
{

this.Dispatcher.Invoke(new updateDelegate(update), DispatcherPriority.Normal);
Thread.Sleep(5);
}
Console.WriteLine("ended thread");
}

void Window1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
running = false;
}
void update()
{
this.InvalidateVisual();
}

No comments: