Dear Gurus!
Silverlight client uses a wcf service to report about the changes in the mssql database. If
I understand correctly, there should be something like:
[OperationContractAttribute(AsyncPattern=true)]publicIAsyncResultBeginServiceAsyncMethod(string msg,AsyncCallback callback,object asyncState){returnAddEventChanges(callback);}public emergEvent EndServiceAsyncMethod(IAsyncResult r){
// Response sent to the clientCompletedAsyncResult<emergEvent> result = r asCompletedAsyncResult<emergEvent>; result.Data.TimeDetected=DateTime.Now;return result.Data;} publicIAsyncResult AddEventChanges(){using(SqlConnection connection =newSqlConnection(connectionString)){using(SqlCommand cmd =newSqlCommand("Select id_event,name,description from dbo.events", connection)){ cmd.Notification=null;SqlDependency dependency =newSqlDependency(cmd); dependency.OnChange+=newOnChangeEventHandler(WaitChange); connection.Open();using(SqlDataReader reader = cmd.ExecuteReader()){}
// return IAsyncResult after WaitChange executed
}}}publicvoidWaitChange(object sender,SqlNotificationEventArgs e){
// Forms answer with emergencyEvent type
// and starts the next cycle of waiting for a response
AddEventChanges();
}
I am interesting how execute AddEventChanges() With a delay before executing WaitChange procedure? Or how to make correctly?