none
Silverlight WCF Service ManualResetEvent.WaitOne will block another request RRS feed

  • Question

  • hi, every one

    as you can see in the picture i have local pc that operate or calculate my request, but not in local it calculate my silverlight request, because some reason i use local pc to calculate my operation.

    i implement my WCF Service some thing like this :

    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
    public class WebClientService {
        private static Queue<ClientServerAction> serverSideCallActionList = new Queue<ClientServerAction>();
        private static Queue<ClientServerAction> serverSideResultActionList = new Queue<ClientServerAction>();
        private static ManualResetEvent server_eventWaitHandle = new ManualResetEvent(false);
        private static ManualResetEvent client_eventWaitHandle = new ManualResetEvent(false);
        //Server Side
        [OperationContract]
        public ClientServerAction Server_FetchNextAction() {
            server_eventWaitHandle.WaitOne();
            lock (serverSideCallActionList) {
                try {
                    return serverSideCallActionList.Dequeue();
                }
                finally {
                    if (serverSideCallActionList.Count == 0) {
                        server_eventWaitHandle.Reset();
                    }
                }
            }
        }
        //Server Side
        [OperationContract]
        public void Server_AddResult(ClientServerAction result) {
            lock (serverSideResultActionList) {
                serverSideResultActionList.Enqueue(result);
            }
            client_eventWaitHandle.Set();
        }
        //Silverlight Side
        [OperationContract]
        public ClientServerAction Client_FetchResult() {
            **client_eventWaitHandle.WaitOne();**
            lock (serverSideResultActionList) {
                try {
                    return serverSideResultActionList.Dequeue();
                }
                finally {
                    if (serverSideResultActionList.Count == 0) {
                        client_eventWaitHandle.Reset();
                    }
                }
            }
        }
        //Silverlight Side
        [OperationContract(IsOneWay = true)]
        **public void Client_CallAction(Guid actionID, string actionName, params ActionParameter[] paramters) {**
            lock (serverSideCallActionList) {
                serverSideCallActionList.Enqueue(new ClientServerAction() {
                    ActionID = actionID,
                    ActionName = actionName,
                    ParametersInfo = paramters
                });
            }
            server_eventWaitHandle.Set();
    
            //return actionID;
        }

    my problem is that two line that is bolded.

    when my silverlight application first time start will call Client_FetchResultAsync and wait for result "client_eventWaitHandle.WaitOne();"

    secound my silverlight application wants to call Client_CallActionAsync to call action in local pc but because first time i called Client_FetchResultAsync and wait for response it cannot call Client_CallActionAsync.

    i set InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple

    and in my web.config

    <system.net>
        <connectionManagement>
          <add address="*" maxconnection="409600" />
        </connectionManagement>
    </system.net>

    but nothing could changed and my application is blocked.

    note that all call in Async Mode...

    i searched but nothing founded

    thanks for you'r help




    Nothing is Impossible in this world, because Impossible itself says that I'm possible

    Saturday, November 30, 2013 6:44 AM

All replies

  • Hi,

    The following configuration taken from MSDN can be applied to enable tracing on your WCF service.

    <configuration>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true" >
            <listeners>
                 <add name="xml"/>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
          <source name="myUserTraceSource"
                  switchValue="Information, ActivityTracing">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
            <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="Error.svclog" />
        </sharedListeners>
      </system.diagnostics>
    </configuration>

    Then use the fiddler to help:
    Silverlight & WCF Debugging and using Fiddler!

    Thanks.

    Friday, December 6, 2013 9:57 AM