Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
GeneralRe: Find color in specific area of screen Pin
Kristian Sixhøj10-Feb-09 23:13
Kristian Sixhøj10-Feb-09 23:13 
AnswerRe: Find color in specific area of screen Pin
musefan10-Feb-09 23:09
musefan10-Feb-09 23:09 
GeneralRe: Find color in specific area of screen Pin
Kristian Sixhøj10-Feb-09 23:13
Kristian Sixhøj10-Feb-09 23:13 
QuestionHow to retrive datatables From Database [modified] Pin
lavankumar10-Feb-09 22:10
lavankumar10-Feb-09 22:10 
AnswerRe: How to retrive datatables From Database Pin
Rob Philpott10-Feb-09 22:28
Rob Philpott10-Feb-09 22:28 
Questioncomparing two datetimepickers Pin
Deresen10-Feb-09 21:59
Deresen10-Feb-09 21:59 
QuestionGetting an Image via web cam using C# Pin
thite_nilesh10-Feb-09 21:49
thite_nilesh10-Feb-09 21:49 
Questionprogressbar further Issue Pin
MumbleB10-Feb-09 21:28
MumbleB10-Feb-09 21:28 
Hi all. I am stuck witha bit of a problem. I am using Threads to do my processing and to update my prgressbar. Below some of the code.
ThreadCode
private void btnRun_Click(object sender, EventArgs e)
{
    ThreadStart excelrun = new ThreadStart(RunExcel);
    Thread startprogress = new Thread(excelrun);
    startprogress.Name = "Update ProgressBar";
    startprogress.Start();
 }

Code in the RunExcel calling the Progressbar thread.
progressBar1.Invoke(new updatebar(this.UpdateProgress));

UpdateProgress Code
private void UpdateProgress()
{
    string filepath;
    filepath = txtboxSelectTxtFile.Text;
    int lines = File.ReadAllLines(filepath).Length;
        progressBar1.Minimum = 0;
        progressBar1.Maximum = lines;
        progressBar1.Value = progressBar1.Value + 1;
        int progrval = 0;
        progrval = progressBar1.Value;
        progrval = progrval + 1;
        lblProgress.Text = ((progrval * 100) / Convert.ToInt32(progressBar1.Maximum)).ToString();
        lblProgress.Refresh();
        lblPercent2.Refresh();
        lblRecordProcessed.Text = progrval.ToString();
        lblProgText.Refresh();
        lblRecordProcessed.Refresh();

}

As you can see from the above that eachtime the progressbar thread is called it does a read of the whole file to obtain the file size which is pretty inefficient. How can I change this to only read the file size once, store the size and use that to determine the Maximum size?

I am stuck and not sure how to get this changed to work more efficiently.

Excellence is doing ordinary things extraordinarily well.

AnswerRe: progressbar further Issue Pin
ABitSmart10-Feb-09 21:57
ABitSmart10-Feb-09 21:57 
GeneralRe: progressbar further Issue Pin
MumbleB11-Feb-09 0:36
MumbleB11-Feb-09 0:36 
GeneralRe: progressbar further Issue Pin
MumbleB11-Feb-09 0:49
MumbleB11-Feb-09 0:49 
GeneralRe: progressbar further Issue Pin
ABitSmart11-Feb-09 1:18
ABitSmart11-Feb-09 1:18 
AnswerRe: progressbar further Issue Pin
Luc Pattyn11-Feb-09 0:36
sitebuilderLuc Pattyn11-Feb-09 0:36 
GeneralRe: progressbar further Issue Pin
MumbleB11-Feb-09 0:52
MumbleB11-Feb-09 0:52 
AnswerRe: progressbar further Issue Pin
Luc Pattyn11-Feb-09 1:02
sitebuilderLuc Pattyn11-Feb-09 1:02 
GeneralRe: progressbar further Issue Pin
MumbleB11-Feb-09 1:06
MumbleB11-Feb-09 1:06 
AnswerRe: progressbar further Issue Pin
Luc Pattyn11-Feb-09 1:42
sitebuilderLuc Pattyn11-Feb-09 1:42 
QuestionHow to call public void with javascript!? Pin
ashkan_ertefa10-Feb-09 21:06
ashkan_ertefa10-Feb-09 21:06 
QuestionIMAGE RETREIVAL PROBLEM FROM ACCESS DATABASE Pin
aashish.saalvi10-Feb-09 20:48
aashish.saalvi10-Feb-09 20:48 
AnswerRe: IMAGE RETREIVAL PROBLEM FROM ACCESS DATABASE Pin
SeMartens10-Feb-09 22:20
SeMartens10-Feb-09 22:20 
GeneralSMS Project Pin
oviyaa10-Feb-09 20:48
oviyaa10-Feb-09 20:48 
GeneralRe: SMS Project Pin
Smithers-Jones10-Feb-09 22:23
Smithers-Jones10-Feb-09 22:23 
GeneralRe: SMS Project Pin
DrawWindow10-Feb-09 23:01
DrawWindow10-Feb-09 23:01 
GeneralRe: SMS Project Pin
Rutvik Dave11-Feb-09 6:48
professionalRutvik Dave11-Feb-09 6:48 
QuestionREgex Pin
lawrenceinba10-Feb-09 20:08
lawrenceinba10-Feb-09 20:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.