Quantcast
Channel: Silverlight 5 forum
Viewing all articles
Browse latest Browse all 1083

WCF ria service and Service Broker - how to work together?

$
0
0

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? 


Viewing all articles
Browse latest Browse all 1083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>