DoEvents() "Hangs"



Group:

We have an application that is calling a stored proc. The stored proc
takes anywhere from 15 to 90 minutes to run.

In order to keep the GUI responsive, we are using a BackgroundWorker to
actually make the call to the stored proc. The app then sits in a loop
that awakes every second and updates an elapsed time value.

The problem that we are having is that after a certain period of time -
which is rarely the same amount - the call to DoEvents hangs (does not
return).

I was hoping the group could help us with: a) why thiat might be
occuring and b) what if anything can be done to fix it.

Here's the key areas of the code:

This is from the method that starts the ball rolling:
.
.
.
case "Consolidate Revenue": {
bgwThread.RunWorkerAsync( cConsolidateRevenue );
SleepAndUpdate();
break;
}
.
.
.

This is from the "DoWork" event handler:

private void bgwThread_DoWork( object sender, DoWorkEventArgs e ) {
switch ((int)e.Argument) {
case cConsolidateRevenue: {
ConsolidateRevenue( cn, dtPickerStartDate.Value.Date,
dateImportEndDate );
break;
}
.
.
.

Here is SleepAndUpdate:
private void SleepAndUpdate( ) {
while (notDone) {
ShowElapsedTime();
Application.DoEvents();
System.Threading.Thread.Sleep( 1000 );
}
}


We have verfied that the app is indeed haning on the call to DoEvents()

Thank you for your help

.



Relevant Pages

  • Re: DoEvents() "Hangs"
    ... Do people really still use DoEvents(). ... We have an application that is calling a stored proc. ... private void bgwThread_DoWork ... private void SleepAndUpdate() { ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: DoEvents() "Hangs"
    ... Couldn't you just make the background thread tell the front end when it is ... We have an application that is calling a stored proc. ... private void bgwThread_DoWork{ ... private void SleepAndUpdate() { ...
    (microsoft.public.dotnet.languages.csharp)

Loading