I have programmed some Web Api controllers to feed a mobile application with data ...
In one of the controls I must wait for a column in a table for a specific ID to change to return a response (in this case a JSON)
I was trying to use SqlDependency but I can not make it work ... In the examples I've seen, a triger is activated when the database changes, but what I really need is to wait for it to change, just as I do not achieve anything. I could make a "Select Status" call every few seconds, but I know it's not the right way ...
I need something like this:
int RequestStatus = await CheckRequestStatusChangeOnDB(RequestID);
//Esperar hasta que CheckRequestStatusChangeOnDB detecte que hubo un cambio y devuelva un valor
if (RequestStatus == 1)
{//hacer algo}
if (RequestStatus == 2)
{//hacer algo}
if (RequestStatus == 0)
{//no hubo cambio en la tabla (después de cierto tiempo sin respuesta)}