1

I am using a self hosted windows service WEB API as the layer between my Windows 8 App and a SQL Server Database because Windows 8 apps can't directly connect to SQL server like win forms or pretty much anything else .net.

The way the process is going to work is that when I make a call to web api from the application, it will insert a row in a specified table. When that happen's, a SQL function is triggered which populates tables with the most current data that I'll need to send to the application.

How can I know when this operation is complete from WEB API's perspective so I know I can query the table and send the data to the client?

  • If you don't need much maybe just use SQLite? Otherwise, depending on timing, you could simply not send a response back to the 'client' until the insert is complete (essentially, local 'remote' function hasn't returned yet). I'm assuming 'self-hosted' means on the client box, and not a cloud server instance somewhere else. – Clockwork-Muse May 20 '15 at 11:37
  • Just have the web-service reply when done? – Morons May 20 '15 at 13:12
1

You can take a look at the tran_locks for an exclusive lock (due to the write access). If the lock is done, everything should be fine.

select * from sys.dm_tran_locks
where resource_database_id = DB_ID(N'YOUR DB')
AND request_session_id = [YOUR SESSION]

Another idea is to take a look at the requests and check if your last request is still running or already sleeping. But that way you need to wait till everything is done. The first idea is better if you just want to ensure that the write process is done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.