Exemple #1
0
        internal void EmployWorker(WorkerCard workerCard, WorkAssignment workAssignment, CommittableTransaction committableTransaction)
        {
            WorkerRunner workerRunner = null;

            switch (workAssignment.WorkRequest.WorkerIsolationLevel)
            {
            case WorkerIsolationLevel.SeparateAppDomain:
                workerRunner = new WorkerRunnerAppDomain(workerCard, workAssignment, committableTransaction);
                break;

            case WorkerIsolationLevel.SeparateProcess:
                workerRunner = new WorkerRunnerProcess(workerCard, workAssignment, committableTransaction);

                // Debug
                //workerRunner = new WorkerRunnerThread(workerCard, WorkAssignment, committableTransaction);
                break;

            case WorkerIsolationLevel.SeparateThread:
            case WorkerIsolationLevel.Default:
            default:
                workerRunner = new WorkerRunnerThread(workerCard, workAssignment, committableTransaction);
                break;
            }

            try
            {
                AllWorkerRunners.Add(workAssignment.WorkerId, workerRunner);
            }
            catch (Exception ex)
            {
                Tracer.Error("AllWorkerRunners.Add({0}) caused exception: {1}", workAssignment.WorkerId, ex);
                foreach (string workerId in AllWorkerRunners.Keys)
                {
                    Tracer.Error("AllWorkerRunners contains worker {0}", workerId);
                }
                throw;
            }
            workerRunner.Run();
        }
        internal void EmployWorker(WorkerCard workerCard, WorkAssignment workAssignment, CommittableTransaction committableTransaction)
        {
            WorkerRunner workerRunner = null;

            switch (workAssignment.WorkRequest.WorkerIsolationLevel)
            {
                case WorkerIsolationLevel.SeparateAppDomain:
                    workerRunner = new WorkerRunnerAppDomain(workerCard, workAssignment, committableTransaction);
                    break;
                case WorkerIsolationLevel.SeparateProcess:
                    workerRunner = new WorkerRunnerProcess(workerCard, workAssignment, committableTransaction);

                    // Debug
                    //workerRunner = new WorkerRunnerThread(workerCard, WorkAssignment, committableTransaction);
                    break;
                case WorkerIsolationLevel.SeparateThread:
                case WorkerIsolationLevel.Default:
                default:
                    workerRunner = new WorkerRunnerThread(workerCard, workAssignment, committableTransaction);
                    break;
            }

            try
            {
                AllWorkerRunners.Add(workAssignment.WorkerId, workerRunner);
            }
            catch (Exception ex)
            {
                Tracer.Error("AllWorkerRunners.Add({0}) caused exception: {1}", workAssignment.WorkerId, ex);
                foreach (string workerId in AllWorkerRunners.Keys)
                {
                    Tracer.Error("AllWorkerRunners contains worker {0}", workerId);                    
                }
                throw;
            }
            workerRunner.Run();
        }