I have a REST web service that is used for comunication with multiple clients, some sort of chat, but I have to make all the changes into the database as soon as the clients comunicate something and then inform all the others clients when a change is made.
I basically get a POST request and I have to reply as soon as an entry is mofified.
Now I make my thread sleep 1 second and then keep recreating the context every second for each request and if there are changes to the database I send the response. This looks ugly to me and I wonder if there is some event or async method to be notified when a specific entry in the database is modified?
Thank you Advance.
If you're using MS SQL Server, you might have success with using Sql Dependencies. Here's a link to a brief tutorial: C# & SqlDependency - Monitoring your database for data changes .
Microsoft's successor to Notification Services, SQL Server 2008 R2 – Complex Event Processing (CEP) Technology might also serve your purposes, but I know nothing about it but what's on the web page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.