mardi 1 septembre 2020

Best Practice for Controller method with Asynchronous Operations

I wish to implement a web api call - a Controller method - that takes a user id and sends out notifications for one or more devices related to that user.

In the Service module, this call will perform 1 asynchronous operation per eligible device.

Because the service operations are asynchronous, there are 2 basic options:

  1. I could return a result to the client immediately and allow it to reconnect for the status of the notifications.

  2. I could wait until all of the asynchronous operations are complete before returning.

Which it considered "best practice"; the former or the latter?




Aucun commentaire:

Enregistrer un commentaire