views:

27

answers:

1

This is following my question: http://stackoverflow.com/questions/2607038/c-how-to-consume-web-service-adheres-to-the-event-based-asynchronous-pattern

My program is calling the DoStuffAsync() x many times in a batch, hence the callback will get invoked the same number of times upon OnComplete().

Is there a way to find out when my batch is finished such that I can generate a report on the success/failed results?

All I can think of is to have a static count variable for x and deduct 1 every time OnComplete() is called, but its kind of silly and error prone I'm afraid.

TIA.

A: 

The way you already mentioned is the way to go. Maybe with a little more effort:

  • Don't hard wire x. Increase it by one every time you call DoStuffAsync().
  • Don't make it static. Instead it is a private field of your class.
  • If it is public static somewhere in the outer world take a look into locking.
Oliver
Thanks a lot, Oliver :-)
codemonkie