Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF. What is the performance difference between async and sync methods on a service?
    primarykey
    data
    text
    <p>lets assume that we have two operation contracts defined on wcf service, sync and async one. There are two samples:</p> <pre><code>public void SubscribeSingle(int userId) { var clientId = this.OperationContext.GetClientId(); var session = this.OperationContext.GetPollingDuplexSession(); if (string.IsNullOrEmpty(clientId) || session == null || userId == 0) { return; } this.InternalSubscribeSingle(userId, clientId, session.SessionId); } </code></pre> <p>and </p> <pre><code>public IAsyncResult BeginUnsubscribeSingle(int userId, AsyncCallback callback, object state) { var clientId = this.OperationContext.GetClientId(); var session = this.OperationContext.GetPollingDuplexSession(); if (string.IsNullOrEmpty(clientId) || session == null) { return null; } var asyncResult = new VoidAsyncResult(callback, state); Task.Factory.StartNew(() =&gt; { try { this.InternalUnsubscribeSingle(userId, clientId); asyncResult.SetAsCompleted(false); } catch (Exception ex) { asyncResult.SetAsCompleted(ex, false); } }); return asyncResult; } public void EndUnsubscribeSingle(IAsyncResult result) { var response = result as VoidAsyncResult; if (response != null) { response.EndInvoke(); } } </code></pre> <p>As I understand WCF service also has a thread pool inside, so each I/O operation may be finished on another thread. As well as starting new thread using Task.Factory.StartNew</p> <p>Is there any difference between sync and async server calls from performance point of view, if database access is made through EntityFramework and though blocking?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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