I wanted to know if is there a way to do something (call function...) every frames in a WPF application, like "update()" in Unity, or like "Application.Idle += new EventHandler(Application_Idle)" in a Winform app ? Thanks.
Asked
Active
Viewed 4,098 times
1
-
update() and Application.Idle are pretty different in their domain context. Are you sure these are the correct ones for your case? – VidasV May 16 '17 at 13:04
-
Maybe, I'm just searching something which can call some code each frame the app is running. – 0_yami_0 May 16 '17 at 13:17
3 Answers
2
Is it related purely to UI rendering events? If so, try looking into CompositionTarget.Rendering event.

VidasV
- 4,335
- 1
- 28
- 50
0
It sounds like you probably want to just use a Dispatcher timer. How do I create a timer in WPF?
The update time in unity is based on many factors but generally at 60 frames a second so the timer interval would be something like 17ms. However you should know wpf doesn't really have frames like unity so there is no update equivalent. It only updates the layout when something moves/added/changed or you call InvalidateLayout to force it to do so.

Community
- 1
- 1

RJ Thompson
- 126
- 7
-1
maybe you could structure your windows constructor like this as in pygame, though I'm not sure it will work
bool running = true;
public someWindow() {
// setup
running = true;
while (running) {
// do stuff
}
}

EverythingLeafwing
- 40
- 7