A
auldh
hello,
i'm having problems getting my three progressbar getting updates.
i created the backgroundworker and enabled the "WorkerReportsProgress =
true". i specified the 3 progressbars in the "private void
bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)".
the back ground worker calls a function, that function is doing construction
of a multiple collection so i want to give the user progress via the
progressbar. but i'm not getting the progressbar to show any progress.
originally i had "private void ListLDN_Start(string[] filenames,
BackgroundWorker worker, DoWorkEventArgs e)" call the three functions with
out including "BackgroundWorker worker, DoWorkEventArgs e". but even if i
continue to pass the background worker i'm still not getting updates.
i'm not understanding or finding any samples on the internet that explain or
help me conquer my problem.
what i'm i doing wrong/missing? clearly i'm doing it wrong but not
successful in finding the problem.
//sample of code...
private void ListLDN_Start(string[] filenames, BackgroundWorker
worker, DoWorkEventArgs e)
{
//starting conerting the listldn into a comma delimited file
:
:
//start the body of the work
lcount = build_master_gspfile(filenames);
build_master_gsparray(lcount, worker, e);
compare_files(lcount, filenames);
//finish the body of the work
}
private int build_master_gspfile(string[] filenames)
{
int lcount = 0; // file list incrementer to walk through the
file list
string data = null; //ra dta string read from input file then
stored in ouput file for later
string temp1 = null, temp2 = string.Empty, site_number = null;
int comma = 0, quote = 0, a = 0;
bool peg = false; //use this to gauge if a record was matched
lcount = 0;
//master file stored in program dir.
StreamWriter sw = new StreamWriter(master_file);
try
{
for (lcount = 0; lcount < filenames.Length; lcount++)
{
:
:
worker.ReportProgress(iSite / 16);
:
:
}//while (sinput.Peek() >= 0)
//should peg not set to turn there was an error in the
gsp file with
//its own site number
if (peg == false)
{
MessageBox.Show("Process stopped because local site
number (" + temp1 +
") is missing in its own file: " +
filenames[lcount] +
". Program error, system Abort.");
Application.Exit();
}
}//for(lcount = 0; lcount < filenames.Length; lcount++)
}
catch (Exception err)
{
ErrorFile ef = new ErrorFile();
:
:
}
sw.Close();
return lcount;
}//private void build_master_gspfile()
private void build_master_gsparray(int lcount, BackgroundWorker
worker, DoWorkEventArgs e)
{
//open the gsp master file and load the master gsp array
int iSite = 0, iElements = 0, iTGSP = 0, iComma = 0;
StreamReader mgsp = new StreamReader(master_file);
mgsp_count = 0; //initialize the elemenst count of number of
gsps stored in
//master gsp array.
//the mater_file is comma delimited and quote defined text format.
//need to read each line and extract the comma elements and
populate
//the master_array(#sites, #elements).
while (mgsp.Peek() >= 0)
{
:
:
if (iElements == 98 && rBngsp.Checked == true)
{
iTGSP = Convert.ToInt16(master_gsp[iSite, 1]);
tgsp_array[iTGSP] = "1";
worker.ReportProgress(iSite / 16);
iSite++;
i = 0;
iElements = 0;
iPlace = 0;
}
if (iElements >= 96 && rBListLDN.Checked == true)
{
if (iElements == 96)
{
master_gsp[iSite, 96] = "";
master_gsp[iSite, 97] = "";
}
if (iElements == 97)
master_gsp[iSite, 97] = "";
iTGSP = Convert.ToInt16(master_gsp[iSite, 1]);
tgsp_array[iTGSP] = "1";
worker.ReportProgress(iSite / 16);
iSite++;
i = 0;
iElements = 0;
iPlace = 0;
}
}//for (int i = 0; iSite < lcount; ++i)
if (iSite == lcount)
break;
}//while (mgsp.Peek() >= 0)
mgsp.Close();
mgsp_count = iSite;
}//private void build_master_gsparray(int lcount)
i'm having problems getting my three progressbar getting updates.
i created the backgroundworker and enabled the "WorkerReportsProgress =
true". i specified the 3 progressbars in the "private void
bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)".
the back ground worker calls a function, that function is doing construction
of a multiple collection so i want to give the user progress via the
progressbar. but i'm not getting the progressbar to show any progress.
originally i had "private void ListLDN_Start(string[] filenames,
BackgroundWorker worker, DoWorkEventArgs e)" call the three functions with
out including "BackgroundWorker worker, DoWorkEventArgs e". but even if i
continue to pass the background worker i'm still not getting updates.
i'm not understanding or finding any samples on the internet that explain or
help me conquer my problem.
what i'm i doing wrong/missing? clearly i'm doing it wrong but not
successful in finding the problem.
//sample of code...
private void ListLDN_Start(string[] filenames, BackgroundWorker
worker, DoWorkEventArgs e)
{
//starting conerting the listldn into a comma delimited file
:
:
//start the body of the work
lcount = build_master_gspfile(filenames);
build_master_gsparray(lcount, worker, e);
compare_files(lcount, filenames);
//finish the body of the work
}
private int build_master_gspfile(string[] filenames)
{
int lcount = 0; // file list incrementer to walk through the
file list
string data = null; //ra dta string read from input file then
stored in ouput file for later
string temp1 = null, temp2 = string.Empty, site_number = null;
int comma = 0, quote = 0, a = 0;
bool peg = false; //use this to gauge if a record was matched
lcount = 0;
//master file stored in program dir.
StreamWriter sw = new StreamWriter(master_file);
try
{
for (lcount = 0; lcount < filenames.Length; lcount++)
{
:
:
worker.ReportProgress(iSite / 16);
:
:
}//while (sinput.Peek() >= 0)
//should peg not set to turn there was an error in the
gsp file with
//its own site number
if (peg == false)
{
MessageBox.Show("Process stopped because local site
number (" + temp1 +
") is missing in its own file: " +
filenames[lcount] +
". Program error, system Abort.");
Application.Exit();
}
}//for(lcount = 0; lcount < filenames.Length; lcount++)
}
catch (Exception err)
{
ErrorFile ef = new ErrorFile();
:
:
}
sw.Close();
return lcount;
}//private void build_master_gspfile()
private void build_master_gsparray(int lcount, BackgroundWorker
worker, DoWorkEventArgs e)
{
//open the gsp master file and load the master gsp array
int iSite = 0, iElements = 0, iTGSP = 0, iComma = 0;
StreamReader mgsp = new StreamReader(master_file);
mgsp_count = 0; //initialize the elemenst count of number of
gsps stored in
//master gsp array.
//the mater_file is comma delimited and quote defined text format.
//need to read each line and extract the comma elements and
populate
//the master_array(#sites, #elements).
while (mgsp.Peek() >= 0)
{
:
:
if (iElements == 98 && rBngsp.Checked == true)
{
iTGSP = Convert.ToInt16(master_gsp[iSite, 1]);
tgsp_array[iTGSP] = "1";
worker.ReportProgress(iSite / 16);
iSite++;
i = 0;
iElements = 0;
iPlace = 0;
}
if (iElements >= 96 && rBListLDN.Checked == true)
{
if (iElements == 96)
{
master_gsp[iSite, 96] = "";
master_gsp[iSite, 97] = "";
}
if (iElements == 97)
master_gsp[iSite, 97] = "";
iTGSP = Convert.ToInt16(master_gsp[iSite, 1]);
tgsp_array[iTGSP] = "1";
worker.ReportProgress(iSite / 16);
iSite++;
i = 0;
iElements = 0;
iPlace = 0;
}
}//for (int i = 0; iSite < lcount; ++i)
if (iSite == lcount)
break;
}//while (mgsp.Peek() >= 0)
mgsp.Close();
mgsp_count = iSite;
}//private void build_master_gsparray(int lcount)