Solved

adding progress bar

Posted on 2011-09-25
2
364 Views
Last Modified: 2012-05-12
Hi

I have an a windows form application that use one class (its name is Parser)
this form has a button and when i click on the windows form application button it call one of the parser class method . this method simply read text file line after line and write each line to separate file.
i would like to add a progress bar to the form in order to show the progress( it is a very large file )

any idea how to do that? I have in the Parse class 2 property one for the number of line in the file and the second how much lines already checked.

here is my button2_Click function

   
private void button2_Click(object sender, EventArgs e)
        {
            if (this.textBox1 != null & this.textBox2 != null)
            {
                inst.init(this.textBox1.Text, this.textBox2.Text);
                //this.progressBar1.Show();
                
                inst.ParseTheFile();
                System.Windows.Forms.MessageBox.Show("Parsing finish successfully"); 
            }
        }

Open in new window

0
Comment
Question by:dpatel_team
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
You need to call ParseTheFile() from a different thread, or use a BackgroundWorker() control.

A good technique would be to make the Parser() class raise a custom Progress() event that you subscribe to.  When that event is received you update the Form via delegates/BeginInvoke() or use the ReportProgress() method of the BackgroundWorker().
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
Comment Utility
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now