Quantcast
Viewing all articles
Browse latest Browse all 12583

WinForms racing condition problem - maybe because of progressbar

Description :

1) Operation is a type that can be run asynchronously. It notifies other objects through it's event namedExecuted , as follows :
                   
_Operation.Executed+= OperationExecuted;

 

2) Inside this event, we call the StopProgress() as follows :

privatevoidOperationExecuted (objectsender,OperationEventArgse)

       {

          StopProgress();

        }

3) The StopProgress() is as shown below :

publicvoidStopProgress()

          {

           if (InvokeRequired)

           {

               Invoke(newMethodInvoker(StopProgress));

               return;

           }

 

           lblTemp.Text="operation complete. ";// 1

           //progressBar1.Visible = false; // 2

          }

********************************************************

When commenting line marked "1" (inside StopProgress() ), and uncommenting "2" (which is the desired behavior), we run into racing condition occasionally(after running the app for 5-10 times, we encounter racing conditions). With line"1", it never happens. There is no exceptions thrown(caught/uncaught) either. We are assuming the problem is related to the "ProgressBar" itself.  If not, what could probably be the case here . Any suggestions on how to track down the racing conditions (vulnerable code sections) are also very much appreciated.

Thanks.


Viewing all articles
Browse latest Browse all 12583

Trending Articles