2

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.

2
  • update() and Application.Idle are pretty different in their domain context. Are you sure these are the correct ones for your case? Commented May 16, 2017 at 13:04
  • Maybe, I'm just searching something which can call some code each frame the app is running. Commented May 16, 2017 at 13:17

3 Answers 3

2

Is it related purely to UI rendering events? If so, try looking into CompositionTarget.Rendering event.

Sign up to request clarification or add additional context in comments.

1 Comment

Not about rendering, only to process.
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.

Comments

-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
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.