• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 553
  • Last Modified:

Screen Refresh issue - WaitforsingleObject- Application.DoEvents()

Hi,

I am exceuting some stored procedures in a loop.
Each of the SPs takes some time to execute.
So, I show a progress disk  and bar on the screen.
The issue is they are not getting refreshed.How do I go about this?
WiatForSingleObject() expects a proc handle; can I use it in this case? I do not want to use Shellexecute.

foreach (string sStoredProc in ListofSP)
            {
                CurrentFileIndex++;
                string sPName = sStoredProc.ToString();
                CurrentScriptName = sPName;

                using (OdbcCommand command = new OdbcCommand("{call " + sPName + "(?)}", OdbcConnection))
                {
                    string test = "{call " + sPName + "(?)}";
                    command.CommandType = CommandType.StoredProcedure;
                   
                    try
                    {
                        command.CommandTimeout = 5 * 60 * 60;
                        OdbcDataReader odbcReader = command.ExecuteReader();
                        odbcReader.Close();
                        command.Parameters.Clear();
                        command.Dispose();
                    }
catch()
{
}
}
0
Enid_JP
Asked:
Enid_JP
  • 2
2 Solutions
 
magicdlfCommented:
Add a Timer and let it refresh the progress bar. You can define a global varible which represent the progress and add it each time your SP execution finishes. Hope that can help you.
0
 
magicdlfCommented:
       private int progress;
        private void timer1_Tick(object sender, EventArgs e)
        {
            progressBar1.Value = progress;
        }
        private void execute()
        {
            foreach (string sStoredProc in ListofSP)
            {
                CurrentFileIndex++;
                string sPName = sStoredProc.ToString();
                CurrentScriptName = sPName;

                using (OdbcCommand command = new OdbcCommand("{call " + sPName + "(?)}", OdbcConnection))
                {
                    string test = "{call " + sPName + "(?)}";
                    command.CommandType = CommandType.StoredProcedure;
                   
                    try
                    {
                        command.CommandTimeout = 5 * 60 * 60;
                        OdbcDataReader odbcReader = command.ExecuteReader();
                        odbcReader.Close();
                        command.Parameters.Clear();
                        command.Dispose();
                        progress++;
                    }
                    catch(...)
                    {
                    }
                }
            }
        }
       
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Move that processing loop into another thread with the BackgroundWorker() control...
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now