sql server - SQLDependency - does not fire while being busy -
is normal behavior sqldependency onchange event not fired if thread busy?
private void notificationonchanged(...) { // database results // simulate long process thread.sleep(10000); }
during sleep add new row , notification lost after sleep expires.
must spawn new single thread work , use flag detect if new notifications arrived restart it?
this behavior artifact of implementation on ado.net notification listener. see http://rusanu.com/2008/01/04/sqldependencyonchange-callback-timing/.
the sqldependency internal thread posts waitfor(receive) not going post 1 until callback returns. have little processing possible , return in onchange event. definetely nothing blocking.
alternatively can use lower level sqlnotificationrequest lets manage everyting, including notification handling. you'll have manage everything. see http://technet.microsoft.com/en-us/library/ms190270(v=sql.105).aspx
Comments
Post a Comment