RockBaby
asked on
Progress Box
Hi,
I need to creating something like a progress box. From my app, when i click save in the SDialog, how can i do something like once i click OK, there will be a Progress Box appear but at the backend, it's saving my document.
SaveFileDialog SDialog = new SaveFileDialog();
SDialog.Filter = "Text Files(*.csv)|*.csv";
if (SDialog.ShowDialog() == DialogResult.OK)
{
frmExecutingRpt frm=new frmExecutingRpt(this);
frm.ShowDialog();
//The progress Box will be appear here but the following code still running..
using (StreamWriter FWriter = new StreamWriter(SDialog.FileN ame))
{
FWriter.WriteLine(DateTime .Now + "\n");
FWriter.WriteLine(",,,,Eve nts Report\n");
FWriter.WriteLine("Alarm Time, Alarm, License No, TID, Latitude, Longitude, POLCOM(Ack),"
+"COSCOM(Ack), POCC(Ack)");
foreach (DataRow datarow2 in streamTable.Rows)
{
FWriter.WriteLine(datarow2 ["license_ n"]);
foreach (DataRow datarow in streamTable.Rows)
{
FWriter.WriteLine(datarow[ "alarmtime _dt"] + "," + datarow["des_x"] + "," + datarow
"license_n"] + "," + datarow["transid_c"] + "," + datarow["lat_n"] + "," + datarow["lon_n"]
+ "," + datarow["pcgack_i"] + "," + datarow["rsnack_i"] + "," + datarow["pocc1ack_i"]);
}
}
FWriter.Close();
frm.Close();
//The progress box will be close here...
Invoke( new ReportGenerationCompleteDe legate( OnReportCompleted ) );
}
}
I need to creating something like a progress box. From my app, when i click save in the SDialog, how can i do something like once i click OK, there will be a Progress Box appear but at the backend, it's saving my document.
SaveFileDialog SDialog = new SaveFileDialog();
SDialog.Filter = "Text Files(*.csv)|*.csv";
if (SDialog.ShowDialog() == DialogResult.OK)
{
frmExecutingRpt frm=new frmExecutingRpt(this);
frm.ShowDialog();
//The progress Box will be appear here but the following code still running..
using (StreamWriter FWriter = new StreamWriter(SDialog.FileN
{
FWriter.WriteLine(DateTime
FWriter.WriteLine(",,,,Eve
FWriter.WriteLine("Alarm Time, Alarm, License No, TID, Latitude, Longitude, POLCOM(Ack),"
+"COSCOM(Ack), POCC(Ack)");
foreach (DataRow datarow2 in streamTable.Rows)
{
FWriter.WriteLine(datarow2
foreach (DataRow datarow in streamTable.Rows)
{
FWriter.WriteLine(datarow[
"license_n"] + "," + datarow["transid_c"] + "," + datarow["lat_n"] + "," + datarow["lon_n"]
+ "," + datarow["pcgack_i"] + "," + datarow["rsnack_i"] + "," + datarow["pocc1ack_i"]);
}
}
FWriter.Close();
frm.Close();
//The progress box will be close here...
Invoke( new ReportGenerationCompleteDe
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
when i tried tat method, the new frame did appear but it seems hang there.. but my code is still running..
In order to get the progress bar running properly you need to run the code on a worker thread.
Are you using .NET 2.0? Take a look at the BackgroundWorker class if you are.
Are you using .NET 2.0? Take a look at the BackgroundWorker class if you are.
ASKER
can i have another thread running in a thread?
s u can
BackgroundWorker is a simple way of doing it..
BackgroundWorker is a simple way of doing it..
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://msdn2.microsoft.com/en-us/library/ms951089.aspx