Evan Cutler
asked on
Progress bar on Form / Progress in Class Function
Greetings.
I have a progress bar on Form1.cs
A button on Form1.cs calls the "click" event, which creates an object
DAT2XLS document = DAT2XLS(sourcefile, schemafile);
Then it executes the function:
DAT2XLS.doyourwork();
I am attempting to do this in the background.
I need to have doyourwork() report progress.
Since it is in a different class, I don't know how to tell the progressbar what the progress is.
I appreciate any wisdom on this.
Thank you.
I have a progress bar on Form1.cs
A button on Form1.cs calls the "click" event, which creates an object
DAT2XLS document = DAT2XLS(sourcefile, schemafile);
Then it executes the function:
DAT2XLS.doyourwork();
I am attempting to do this in the background.
I need to have doyourwork() report progress.
Since it is in a different class, I don't know how to tell the progressbar what the progress is.
I appreciate any wisdom on this.
Thank you.
ASKER
ok.
I read the article, but a bit confused.
Here's my form code:
and Here's my class (some of it):
ok...how do I tell ETLRUN() to throw the percentage back to ProgressChanged in the form class? Thanks.
I read the article, but a bit confused.
Here's my form code:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
DAT2XLS D2X = new DAT2XLS(TXTBinFile.Text, TXTXMLSchemaFile.Text);
D2X.ETLRUN();
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
PBXFR.Value = e.ProgressPercentage;
}
and Here's my class (some of it):
public class DAT2XLS
{
String DatFile;
String SchemaFile;
public DAT2XLS(String Dat, String Schema)
{
DatFile = Dat;
SchemaFile = Schema;
}
public void ETLRUN()
{
//sudocode here
open file;
totallines; //gives the "100%"
start file back at top;
linecount = 0;
do while (!end of file)
read line, do something //gives current line
percent = linecount / totallines;
SEND PERCENT VALUE BACK TO PROGRESSCHANGED
}
ok...how do I tell ETLRUN() to throw the percentage back to ProgressChanged in the form class? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all of your help...
I'm having issues still
D2X_Progress is not sending the value to ProgressChanged (I think)...
or ProgressChanged is not accepting something.
The PBXFR.Value is not updating.
Thank you so much for walking me through this.
I'm having issues still
D2X_Progress is not sending the value to ProgressChanged (I think)...
or ProgressChanged is not accepting something.
The PBXFR.Value is not updating.
Thank you so much for walking me through this.
ASKER
Never mind, it was my calculations that didn't push the value.
THANK YOU SO MUCH!!!!
This worked perfectly.
This is an invaluable tool.
THANK YOU SO MUCH!!!!
This worked perfectly.
This is an invaluable tool.
http://www.switchonthecode.com/tutorials/csharp-snippet-tutorial-custom-event-handlers