c# - Sqldependency - Records added while processing -


i have question on sql dependency. lets assume application receives notification when underlying query data changes , planning select data table, process , resubscribe/start dependency again. if processing takes 1-2 minutes , in mean time there may data added during processing time. not sure how data notified or have wait next change occur can few minutes hrs?

below sample code let me know if missing something

code:

    private void loadnotifications()     {         datatable dt = new datatable();         using (sqlcommand command = new sqlcommand("select id dbo.notifications", m_sqlconn))         {             command.notification = null;              sqldependency dependency = new sqldependency(command);             dependency.onchange += new onchangeeventhandler(ondependencychange);              if (m_sqlconn.state == connectionstate.closed)             {                 m_sqlconn.open();             }                //using (sqldatareader reader = command.executereader())             //{             //    if (reader.hasrows)             //    {                     //lets assume takes 2-3 minutes             //    }             //}          }     }      private void ondependencychange(object sender, sqlnotificationeventargs e)     {         sqldependency dependency = sender sqldependency;         dependency.onchange -= ondependencychange;         loadnotifications();     } 

what you're describing typical non-synchronous nature of data changes , app notification. in short, changes may happening , app not see them happen in real-time. furthermore, changes may going on whether or not front-end app open. there requirement see data being changed in order make decisions on front-end app or need review data changes made other users. 1 way in might achieve either queue of changes in form of table populated underlying trigger. code front-end app periodically read table , mark them read. allow de-couple data changes app views , maybe see processing performance increases.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -