Exemple #1
0
        void StartThread(object threadNumber)
        {
            double sumTotalMilliseconds = 0;

            for (int i = 0; i <= ControllerTest.Storage.StorageObject.Calls - 1; i++)
            {
                if (stop)
                {
                    break;
                }
                Stopwatch watch = new Stopwatch();
                watch.Start();
                isvcRes = _RemoteObj.ExecuteService(string.Empty, isvcReq);
                //System.Threading.Thread.Sleep(300);
                watch.Stop();

                if (isvcRes.Error != null)//--->  error FIN
                {
                    if (FinalizeEvent != null)
                    {
                        FinalizeEvent(isvcRes.Error.Message);
                    }
                    lock (thisLock)//seccion critica
                    {
                        stop = true;
                    }
                }
                if (CallEvent != null)// avisa que se ejecuto una llamada
                {
                    CallEvent();
                }
                sumTotalMilliseconds += watch.Elapsed.TotalMilliseconds;
            }


            double AVERAGE = sumTotalMilliseconds / ControllerTest.Storage.StorageObject.Calls;

            if (MessageEvent != null)
            {
                MessageEvent("Thread Nº", (int)threadNumber, AVERAGE, sumTotalMilliseconds);
            }

            doneEvents[(int)threadNumber].Set();

            if ((int)threadNumber + 1 == doneEvents.Length)
            {
                if (FinalizeEvent != null)
                {
                    FinalizeEvent("");
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Ejecuta un servicio de negocio.
        /// Si se produce el error:
        /// The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
        /// Se debe a un error que lanza una llamada asincrona en modo debug
        /// </summary>
        /// <param name="req">Clase que imlementa la interfaz IServiceContract datos de entrada para la  ejecución del servicio.</param>
        /// <returns>Clase que imlementa la interfaz IServiceContract con datos de respuesta del servicio.</returns>
        /// <returns>response</returns>
        public TResponse ExecuteService <TRequest, TResponse>(TRequest req)
            where TRequest : IServiceContract
            where TResponse : IServiceContract, new()
        {
            FwkRemoteObject wFwkRemoteObject = CreateRemoteObject();
            TResponse       response;

            try
            {
                req.InitializeHostContextInformation();
                response = (TResponse)wFwkRemoteObject.ExecuteService(_ServiceMetadataProviderName, req);
                response.InitializeHostContextInformation();
            }
            catch (Exception ex)
            {
                response       = new TResponse();
                response.Error = ProcessConnectionsException.Process(ex, "");
            }


            return(response);
        }