c# - How to enable SqlDependency OnChange event to handle multiple requests at a time -
when work sqldependency
, work ondatachange
event , event notifies regarding data change in table. suppose application monitoring test
table using sqldependency
, , suppose huge amounts of data getting inserted , updated in test
table frequently. not know how sqldependency's ondatachange
event can handle situation because ondatachange
event fire data changes in db table.
here snippet of code onchange
event:
void ondatachange(object sender, sqlnotificationeventargs e) { ((sqldependency)sender).onchange -= ondatachange; bbalogger.write("partindexer service registernotification called end", bbalogger.msgtype.info); if (e.source == sqlnotificationsource.timeout) { mailsend(); // notification mail send bbalogger.write("partindexer service sqlnotificationsource.timeout error", bbalogger.msgtype.error); environment.exit(1); } else if (e.source != sqlnotificationsource.data) { mailsend(); // notification mail send bbalogger.write("partindexer service sqlnotificationsource.data", bbalogger.msgtype.error); environment.exit(1); } else if (e.type == sqlnotificationtype.change) { startindex(); bbalogger.write("partindexer service data changed", bbalogger.msgtype.info); } else { bbalogger.write(string.format("ignored change notification {0}/{1} ({2})", e.type, e.info, e.source), bbalogger.msgtype.warnings); } registernotification(); }
i'm looking in designing ondatachange
event in such way if data changed very frequently in test
table, ondatachange
can handle situation. ondatachange
event should not freeze , should log each data change in xml file.
Comments
Post a Comment