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 8773903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:25:31+00:00 2026-06-13T18:25:31+00:00

First here’s the code. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;

  • 0

First here’s the code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace winform_project
{
  public partial class Form1 : Form
  {
    void movement_correct(PictureBox pic, int i)
    {
        System.Threading.Thread.Sleep(25);
        pic.Top += (i - 1);
        pic.Left += (i + 3);
    }

    void movement_up(PictureBox pic, int i)
    {
        System.Threading.Thread.Sleep(25);
        pic.Top -= (i - 1);
        pic.Left -= (i + 3);
    }
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < 5; i++)
        {
            movement_correct(pictureBox1, i);
            movement_correct(pictureBox2, i);
            movement_correct(pictureBox3, i);
            movement_correct(pictureBox4, i);
            movement_correct(pictureBox5, i);
            movement_correct(pictureBox6, i);
            movement_correct(pictureBox7, i);
            movement_correct(pictureBox8, i);
            movement_correct(pictureBox9, i);
            movement_correct(pictureBox10, i);
        }

        for (int i = 0; i < 5; i++)
        {
            movement_up(pictureBox1, i);
            movement_up(pictureBox2, i);
            movement_up(pictureBox3, i);
            movement_up(pictureBox4, i);
            movement_up(pictureBox5, i);
            movement_up(pictureBox6, i);
            movement_up(pictureBox7, i);
            movement_up(pictureBox8, i);
            movement_up(pictureBox9, i);
            movement_up(pictureBox10, i);
        }

    }
 }
}

There are 10 dummy picture boxes. Whenever i click the button they start to move a bit(sort of like the enemies in space invaders).

I am trying to make a smooth animation in winforms. The problem is that the animation in not as smooth as i want it to be. In my code all the boxes aren’t moving simultaneously, there is a little bit of noticeable gap in their movement. What i want is smooth movement.

I was thinking of multi threading it but then realized it would mean one thead for each objects. Is there any other way(Within winforms).

Thanks for the help.

  • 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-13T18:25:33+00:00Added an answer on June 13, 2026 at 6:25 pm

    Using Thread.Sleep(n) for timing purposes is a guaranteed way of not getting smooth animation; this is because the value passed to Thread.Sleep is treated by the OS as a minimum sleep time, meaning that the actual duration of the sleep can be (and usually is) a bit longer. You should instead drive your animation using QueryPerformanceCounter.

    Even with a proper high-resolution timing engine, you will still have “tearing” effects.

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

Sidebar

Related Questions

Setup Using MVC 3 + Code First Here are my classes public class Member
First here's what I'm using and trying to do: the minimal setup for this
First post here... I normally develop using PHP and Symfony with Propel and ActionScript
First off here is the code! <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
first post here, and probably an easy one. I've got the code from Processing's
So first here is some pseudo code of what I want to improve. public
first here is my html demo code <div class=wrapper> <div class=item></div> <div class=item></div> <div
first here is my html code: <div class=outter> <div class=item></div> <div class=item></div> <div class=item></div>
First here's the code: <?php $qty = $_GET['qty']; for($i=0; $i < $qty; $i++) {
i am using codeigniter library, and am stuck in a matter. first here's my

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.