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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:27:40+00:00 2026-05-15T11:27:40+00:00

In my project, whenever a long process in being executed, a small form is

  • 0

In my project, whenever a long process in being executed, a small form is displayed with a small animated gif file. I used this.Show() to open the form and this.Close() to close the form.
Following is the code that I use.

public partial class PlzWaitMessage : Form
{
   public PlzWaitMessage()
   {
      InitializeComponent();
   }

   public void ShowSpalshSceen()
   {
      this.Show();
      Application.DoEvents();
   }

   public void CloseSpalshScreen()
   {
      this.Close();
   }
}

When the form opens, the image file do not immediately start animating. And when it does animate, the process is usually complete or very near completion which renders the animation useless. Is there a way I can have the gif animate as soon as I load the form?

  • 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-05-15T11:27:41+00:00Added an answer on May 15, 2026 at 11:27 am

    Why not using threads? It’s always good idea to learn something new.

    You could simply put your “long process” in background thread, and use events to report to presentation layer, for example:

    // in your "long process" class
    public event Action<double> ReportCompletition;
    
    // this method will start long process in separate background thread
    public void Start()
    { 
        Thread thread = new Thread(this.LongProcess);
        thread.IsBackground = true;
        thread.Start();
    }
    
    private void LongProcess()
    {
        // do something
        // report 10% completition by raising event
        this.ReportCompletition(0.1);
        // do something more
        this.ReportCompletition(0.5);
        // ... and so on
    }
    

    This way, all you have to do is implement simple method in your Form/UI, which will consume this information.

    public partial class MainApplicationWindow : Form
    {
        private LongProcessClass _longProcess;
    
        public MainApplicationWindow
        {
            this.InitializeComponent();
            this._longProcess = new LongProcessClass();
            // bind UI updating method to long process class event
            this._longProcess.ReportCompletition += this.DisplayCompletitionInfo;
        }
    
        private void DisplayCompletitionInfo(double completition)
        {  
            // check if control you want to display info in needs to be invoked
            // - request is coming from different thread
            if (control.InvokeRequired)
            {
                Action<double> updateMethod = this.DisplayCompletitionInfo;
                control.Invoke(updateMethod, new object[] { completition });
            }
            // here you put code to do actual UI updating, 
            // eg. displaying status message
            else
            {
                int progress = (int) completition * 10;
                control.Text = "Please wait. Long process progress: " 
                    + progress.ToString() + "%";
            }
        }
    

    Of course, you can report anything you like from within long process. Be it completition rate, ready to display string messages, anything. You can also use events to report that long process has finished, broke, or any long process data you wish.

    For more detailed information on this topic you might want to check MSDN tutorials on Threading and Events.

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

Sidebar

Related Questions

i got this error whenever i trying execute my project which is used database
Alright, I'm doing this for a project and whenever I attempt to have it
I was trying to incorporate file upload to my project but whenever I access
On my localhost if I'm working on a project in http://localhost/ project_name / whenever
Whenever I create a new project in the Visual Studio 2010 Release Candidate, for
Whenever we make a release of a project we'll create a tag to capture
Whenever I load a solution in Visual Studio with a specific project set as
On a MVC3 project I'm working on whenever I do a redirect to action
In a current project (480 source files), whenever i add a new module, i
I am using an iframe in my project and it seems that whenever it

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.