I have a silly problem but i am stuck. I am executing a stored procedure form my code procedure takes time so for this I am displaying a progress bar, which shows the progress of execution, but stored procedure executes and there is nothing to which I increment the value of progress bar.
This is my code
void btnYes_Click(object sender, EventArgs e)
{
if (DialogResult.Yes == MessageBox.Show("Are you sure", "", MessageBoxButtons.YesNo))
{
try
{
dbDataEntities db = new dbDataEntities();
string myquery = "DECLARE @return_value int EXEC @return_value = [dbo].[ssspUpdateMarksOfStudent] SELECT 'Return Value' = @return_value";
//progressbar1.Maximum = 5000;
//progressbar1.value = ?; // how could i increment it
//
db.Database.ExecuteSqlCommand("myquery");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
Also i try to do it with stopwatch by setting the current value which did not increment while execution of procedure
Stopwatch st = new Stopwatch();
st.Start();
progressbar1.Maximum = 5000;
progressbar1.Value = Convert.ToInt16(st.Elapsed.Seconds);
//My stored procedure call
st.Stop();
so is it can only be done by using background worker
or is there any other way to do this?
I am new to programming so did not use background worker
much so i am trying to find an alternative.
Please suggest. Thanks in advance.