Avoiding infinite loop on datarow changes

  • Thread starter Thread starter Whuggy
  • Start date Start date
W

Whuggy

Hi.

I have a DataTable class that interfaces with the QuickBooks SDK. The class
subscribes to its own RowChanged event and in the handler method, it does a
select and in case of a DataRowAction.Change, another method is called to
(a) put the updated row values in QuickBooks, and (b) get a field that
QuickBooks automatically updates back to the updated DataRow.

The problem happens in that step (b). What is happening is the updating
function fires the RowChanged event and in turn calling itself along the
way. I wonder what is the correct technique for this scenario.
 
Hi Whuggy,

I would put a flag at class level.
Within rowchanged:
if (!flag)
{
flag = true;
try
{
do processing
}
finally
{
flag = false;
}

}

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top