Reputation: 4941
I have a question about the usage of SqlDependency in .NET. I've read the documentation, but it's still not clear to me if the OnChange event gets called in its own thread. So for example, if I get 30 concurrent events, do they each get their own OnChange even handler? The reason I'm asking is I don't want to create an engine with this if the work that's being done in the OnChange handler is blocking the next event.
For example, I have a SqlDependency for an Orders database, and every time there's a new order, I receive the OnChange event and then I can process the user's order. This will not hold up others coming in, correct?
Also, do you see any problems using this method? SqlDependency seems like a really powerful feature, so I hope it works this way. ;)
Thanks
Upvotes: 2
Views: 1054
Reputation: 1044
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency.aspx
According to a note in the msdn info on the SQLDependancy Class in the link above, quote->
"The OnChange event may be generated on a different thread from
the thread that initiated command execution. "
On the other hand, on the same page is the following note, quote->
"SqlDependency was designed to be used in ASP.NET or middle-tier
services where there is a relatively small number of servers
having dependencies active against the database. It was not
designed for use in client applications, where hundreds or
thousands of client computers would have SqlDependency
objects set up for a single database server. "
Upvotes: 4