Note that there are some explanatory texts on larger screens.

plurals
  1. POQueueing up Service Calls
    text
    copied!<p>I'm implementing a Silverlight application that uses WCF services heavily, I've got to the point now where occasionally there are several long service calls that block other service calls from running.</p> <p>These service calls eventually time out. I'd like to see if its possible to a queue system that executes service calls one after another, this way long calls will hold up other calls but won't cause them to timeout.</p> <p>I'm using service agents to wrap the service calls</p> <pre><code>public interface IExampleServiceAgent { void ProcessData(int a, string b, EventHandler&lt;ProcessDataCompletedEventArgs&gt; callback); } Public ExampleServiceAgent1 : IExampleServiceAgent { ExampleClient _Client = new ExampleClient(); public void ProcessData(int anInt, string aString, EventHandler&lt;ProcessDataCompletedEventArgs&gt; callback) { EventHandler&lt;ProcessDataCompletedEventArgs&gt; wrapper = null; wrapper = (a,b) =&gt; { callback(a,b); _Client.ProcessDataCompleted -= wrapper; } _Client.ProcessDataCompleted += wrapper; _Client.ProcessDataAsync(anInt,aString); } } </code></pre> <p>The above service agent would then be called from code as follows:</p> <pre><code>ServiceAgent.ProcessData(1,"STRING", (a,b) =&gt; { if (b.Error != null) { //Handle Error } else { //DO something with the data } } </code></pre> <p>Is there a way I could put these service calls into a queue and execute them one by one?</p> <p>I've tried wrapping them as Actions and adding them to a queue, but this does not wait for one to finish executing before starting the next one and although they do call the service correctly no data is returned to the calling ViewModel.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload