0

I have this client application that sends thousands of items for deletion to my wcf service. Since the data is sent in bulk, even if I cancel the operation (with progress bar), all items are deleted. The behavior I want is to be able to cancel the delete operation in the service and retrieve items that are not deleted. Thank you.

  • 1
    Don't think about the service yet - how would you do this in the database or whatever persistent store? Do you have a way to cancel the delete at all? – John Saunders Jul 29 '11 at 02:45
  • The items are removed one by one in the database, I need something to interrupt the operation and return back the items that are not deleted. I hope I answer your question correctly. Thanks. – jimbo cortes Jul 29 '11 at 03:04
  • Sounds more complicated than necessary, really. – John Saunders Jul 29 '11 at 03:09

1 Answers1

0

What InstanceContextMode are you using?

What you want to do will work with InstanceContextMode Singleton or Session, but not PerCall.

I suppose that your method that initiates the delete in bulk operation is OneWay.

Create a bool field (initially false) in your service. Your loop that deletes records one by one checks that flag and stops if the flag is true.

Create another method in your service that sets that field to true. Call the new method from your website when you press the "Cancel Delete" button. The looop for deleting records will break.

Returning the records that were not deleted will be a bit tricky. Your list of records to delete will need to be a memebr of the service class also, so that the method that stops the delete has access to the list also. The method that deletes from the db shoulkd also remove the records from the list one by one so you can keep track of remaining items.

You could return immediately in the second method the list, but thia does not guarantee accurate results. What I would do is do a wait of 200 ms before returning. That way you know that the item removed from the list is really deleted in the db.

Hope this is clear...

Voicu
  • 38
  • 4
  • Yes, InstanceContextMode is PerSession and the delete operation is OneWay. I get your point, i'll try and see what happens. As for the remaining undeleted items, maybe I don't have to get them back. I'll try to perform another operation to refresh items on the client side. Thanks. – jimbo cortes Jul 29 '11 at 08:27