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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:32:18+00:00 2026-06-08T07:32:18+00:00

If I click one by one click leave the arrow key then a click

  • 0

If I click one by one click leave the arrow key then a click and leave again and so on the images are change good.
But if I keep pressing the right arrow key nonstop the images dosent change only when I leave the right arrowkey where it stopped so the image in this trackBar value loaded.

This is my scroll event:

private void trackBar1_Scroll(object sender, EventArgs e)
{   
    currentFrameIndex = trackBar1.Value;
    textBox1.Text = "Frame Number : " + trackBar1.Value;
    wireObject1.woc.Set(wireObjectAnimation1.GetFrame(currentFrameIndex)); 
    LoadPictureAt(trackBar1.Value, sender);

    button1.Enabled = false;
    button2.Enabled = false;
    button3.Enabled = false;
    button4.Enabled = false;
    button8.Enabled = false;
    SaveFormPicutreBoxToBitMapIncludingDrawings();
    return;
}

I have no other events of the trackBar so far.

This is the LoadPictureAt function:

private bool LoadPictureAt(int nIndex, object c)
{
    bool bRet = false;
    if (nIndex >= 0 && nIndex < fi.Length)
    {
        if (c.Equals(trackBar1))
            pictureBox1.Load(fi[nIndex].FullName);
        bRet = true;
    }   
    return bRet;
}

I SOLVED IT :

I added a new function before my scroll event:

private void setpicture(int indx)
        {
            if (fi == null)
            {

            }
            else
            {
                if (indx >= 0 && indx <= trackBar1.Maximum && fi.Length > indx)
                {
                    try
                    {
                        label19.ForeColor = Color.Red;
                        fileToolStripMenuItem.Enabled = true;
                        label19.Visible = false;
                        label20.Visible = false;
                        label14.Visible = true;
                        label15.Visible = true;
                        label8.Visible = true;
                        label9.Visible = true;

                        trackBar1.Enabled = true;
                        using (FileStream fs = new FileStream(fi[indx].FullName, FileMode.Open))
                        {
                            this.label8.Visible = true;
                            this.label9.Visible = true;
                            this.label9.Text = fi[indx].Name;
                            Image img = null;
                            Bitmap bmp = null;
                            Image imgOLd = null;

                            try
                            {


                                img = Image.FromStream(fs);
                                bmp = new Bitmap(img);

                                imgOLd = this.pictureBox1.Image;
                                this.pictureBox1.Image = bmp;
                                if (imgOLd != null)
                                    imgOLd.Dispose();

                                img.Dispose();
                                img = null;
                            }
                            catch
                            {
                                if (img != null)
                                    img.Dispose();
                                if (bmp != null)
                                    bmp.Dispose();
                                if (imgOLd != null)
                                    imgOLd.Dispose();
                            }
                        }
                    }
                    catch
                    {

                    }
                }
                else
                {
                    Image imgOLd = this.pictureBox1.Image;


                    if (imgOLd != null)
                    {
                        imgOLd.Dispose();
                        imgOLd = null;
                    }

                    Application.DoEvents();
                }
            }
        }

And changed the scroll event to:

private void trackBar1_Scroll(object sender, EventArgs e)
        {

            currentFrameIndex = trackBar1.Value;
            textBox1.Text = "Frame Number : " + trackBar1.Value;
            wireObject1.woc.Set(wireObjectAnimation1.GetFrame(currentFrameIndex)); 

            trackBar1.Minimum = 0;
            trackBar1.Maximum = fi.Length - 1;
            setpicture(trackBar1.Value);
            pictureBox1.Refresh();

            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = false;
            button8.Enabled = false;
            SaveFormPicutreBoxToBitMapIncludingDrawings();
            return;









        }
  • 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-08T07:32:19+00:00Added an answer on June 8, 2026 at 7:32 am

    There’s no such thing as “non-stop” when you hold down a cursor key or slam it repeatedly as fast as you can. The KeyDown event for it is generated at a glacial pace to modern cpus. You can’t do much better than about 20 hits per second, 50 milliseconds between each hit. A modern core can easily execute a hundred million instructions between keystrokes.

    What matters however is what you do with that enormous resource. Unfortunately you don’t do much, you are hitting this disk in the Scroll event. You call Image.Load() and, what looks like, Image.Save(). Those are methods that can only execute as fast as the disk rotates, the cpu isn’t doing anything useful while it waits for the disk to do its job. A hundred million cpu cycles wasted waiting for a mechanical event to happen.

    It actually gets worse from there. The next thing that happens is that Winforms needs to paint the window with the image retrieved from the disk. Painting is a low priority operation, it is only done when nothing more important needs to be done.

    Problem is, there is something more important that needs to be done. Waiting for the disk to retrieve/save the image took so long that the next thing that the Winforms message loop encounters is something more important than painting. An input event, the next keystroke.

    Which gets properly executed, your picture box actually gets its Image assigned. You just can’t see it because it didn’t get painted to the screen. Stop hitting the cursor key and bam, it now has time and paints.

    This is all very much by design. You can force a repaint by calling the picture box’ Update() method, the user will now definitely see the image. But that doesn’t actually work very well either, your program starts to lag. The keystrokes are buffered in the message queue and your program will keep updating the image long after you released the key.

    Pick your poison.

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

Sidebar

Related Questions

when i click on one panel link hello or Hi, then that panel must
Can someone explain how the Silverlight 4 OOB upgrades happen? Is it click one?
I'm creating one-click python installer (integrated with my application). Is there any way to
This probably has a one click solution, i know debugging web pages in VS2010
I want to have a one-click excel export feature for my application. I therefore
In my application when I click on one of my button in the page
This is a 2 part question: 1) click on one of the demo dropdowns
I recently installed the phpBB app using the one click function (I have a
In order to get my setup a bit closer to one click deployment, I
Javascript jQuery event handling If on event (for example 'click') bound one function for

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.