Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9140453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:31:06+00:00 2026-06-17T09:31:06+00:00

In my WPF application, the user presses a button to start a 3D model

  • 0

In my WPF application, the user presses a button to start a 3D model rotating smoothly, and lets up on the button to stop the rotation.

To do this, I create a DispatcherTimer:

DispatcherTimer timer = new DispatcherTimer();
timer.Tick += new EventHandler( timer_Tick );
timer.Interval = new TimeSpan( 0, 0, 0, 0, 30 );

And when the button is pressed I call timer.Start() and when the button is let up I call timer.Stop().

The timer_Tick function changes the rotation of the model:

    void timer_Tick( object sender, EventArgs e )
    {
        spin = ( spin + 2 ) % 360;
        AxisAngleRotation3D rotation = new AxisAngleRotation3D( new Vector3D( 0, 1, 0 ), spin );
        Transform3D rotate = new RotateTransform3D( rotation );
        model2.Transform = rotate;
    }

What I notice is that the model spins smoothly for the most part, but often freezes and stutters, pausing for various durations, sometimes up to like 1/4 second.

Is there a way to make this smoother? I understand that by using DispatcherTimer (as opposed to, say, System.Timers.Timer) the callbacks happen on the UI thread. But it’s necessary for me to be on the UI threat in order to run the line

        model2.Transform = rotate;

I have read about various ways to get a timer callback on some other thread. But it seems like in the end I have to synchronize with the UI thread to call that line. If I use Invoke() to marshal from, say, the System.Timers.Timer callback thread to the UI thread, will that give an overall smoother animation? It seems like it shouldn’t, since it’s having to synchronize with the UI thread just like DispatcherTimer presumably does. And for that matter it seems like any scheme for setting model2.Transform on a regular interval would be in the same boat with respect to the UI thread, no?

(As a perhaps secondary question, I’m trying to understand what’s causing the pauses in the first place. As far as I can know, there’s nothing else significant that the UI thread is doing. So I don’t understand what’s happening during those pauses. Garbage collection? It doesn’t seem like there should be much garbage to collect, and it doesn’t seem like the pause would be so extreme.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:31:06+00:00Added an answer on June 17, 2026 at 9:31 am

    Set a priority. The default is Background, that might explain the stuttering you see. I think Render is the level you want but do experiment.

    DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.Render);
    

    If that isn’t smooth enough you could try setting it up as an Animation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a user control within a WPF application that will
I want to create a WPF application that allows the user to create graphical
I have a WPF application that has user validation. This is rendered in the
(Using WPF application) This is the situation: There are 3 user input fields. 1
I have created a wpf application into which I have added a user control
I have WPF Application where I have One main form and other user controls
I have a WPF application, where when a user unchecks a checkbox, the application
If we want in our WPF application to let a user make a SQL
I have a service that spawns a WPF application process when a user logs
I'm trying to change some config file user settings values in my WPF application,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.