private void IncreaseDequeueProcessThreads(int count)
 {
     for (int i = 0; i < count; i++)
     {
         if (_waitingDequeueThreadsProcessorsStack == null)
         {
             _waitingDequeueThreadsProcessorsStack = new KeyedStack <ThreadProcessor>();
         }
         var processor = new ThreadProcessor
                         (
             this
             , new AutoResetEvent(false)
                         );
         var thread = new Thread
                      (
             new ThreadStart
             (
                 processor.ThreadProcess
             )
                      );
         if (_callbackProcessBreaksActions == null)
         {
             _callbackProcessBreaksActions = new ConcurrentQueue <Action>();
         }
         var callbackProcessBreakAction = new Action
                                          (
             processor.StopOne
                                          );
         _callbackProcessBreaksActions.Enqueue(callbackProcessBreakAction);
         _waitingDequeueThreadsProcessorsStack.TryPush(processor);
         //Console.WriteLine(_dequeueThreadsProcessorsPool.Count);
         thread.Start();
     }
 }
 private void IncreaseDequeueProcessThreads(int count)
 {
     for (int i = 0; i < count; i++)
     {
         Interlocked.Increment(ref _concurrentDequeueThreadsCount);
         if (_dequeueThreadsProcessorsPool == null)
         {
             _dequeueThreadsProcessorsPool = new ConcurrentQueue <ThreadProcessor>();
         }
         var processor = new ThreadProcessor
                         (
             this
             , new AutoResetEvent(false)
                         );
         var thread = new Thread
                      (
             new ThreadStart
             (
                 processor.ThreadProcess
             )
                      );
         if (_callbackProcessBreaksActions == null)
         {
             _callbackProcessBreaksActions = new ConcurrentQueue <Action>();
         }
         var callbackProcessBreakAction = new Action
                                          (
             processor.StopOne
                                          );
         _callbackProcessBreaksActions.Enqueue(callbackProcessBreakAction);
         _dequeueThreadsProcessorsPool.Enqueue(processor);
         thread.Start();
     }
 }
Esempio n. 3
0
 private void BeginRestartingIIS(List <BaseAction> actions)
 {
     if (threadProcessor == null)
     {
         threadProcessor                  = new ThreadProcessor();
         threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
         threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_Executing);
         threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_Executed);
     }
     threadProcessor.AsyncRunAllWorkUnits(actions);
 }
Esempio n. 4
0
 private void BeginRecyclingAppPools(List <BaseAction> actions)
 {
     // Initialize thread
     if (threadProcessor == null)
     {
         threadProcessor                  = new ThreadProcessor();
         threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
         threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_Executing);
         threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_Executed);
     }
     threadProcessor.AsyncRunAllWorkUnits(actions);
 }
Esempio n. 5
0
 private void BeginImportingPublishingBrl(List <BaseAction> actions)
 {
     // Initialize thread
     if (threadProcessor == null)
     {
         threadProcessor                  = new ThreadProcessor();
         threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
         threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_IPExecuting);
         threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_IPExecuted);
     }
     threadProcessor.AsyncRun(actions);
 }
Esempio n. 6
0
 private void BeginCheckingWebServiceStatus(List <BaseAction> actions)
 {
     this.FormState = FormStateEnum.Processing;
     if (threadProcessor == null)
     {
         threadProcessor                  = new ThreadProcessor();
         threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
         threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_CheckWebServiceExecuting);
         threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_CheckWebServiceExecuted);
     }
     threadProcessor.AsyncRunAllWorkUnits(actions);
 }
Esempio n. 7
0
 private void BeginCreatingAppOnCheckedServer(List <BaseAction> actions)
 {
     if (threadProcessor == null)
     {
         threadProcessor                  = new ThreadProcessor();
         threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
         threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_Executing);
         threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_Executed);
     }
     ActionFactory.UpdateActions(actions, GetCreateAppActionParameters());
     threadProcessor.AsyncRunAllWorkUnits(actions);
 }
Esempio n. 8
0
 private void BeginSavingInstances(List <BaseAction> actions)
 {
     isInterrupted  = false;
     this.FormState = FormStateEnum.Processing;
     if (threadProcessor == null)
     {
         threadProcessor                  = new ThreadProcessor();
         threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_SavingCompleted);
         threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_SavingActionExecuting);
         threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_SavingActionExecuted);
     }
     threadProcessor.AsyncRunControlledWorkUnits(actions, Environment.ProcessorCount);
 }
Esempio n. 9
0
        private void BeginActionOnServiceStartupType(List <BaseAction> actions)
        {
            this.FormState = FormStateEnum.Processing;

            // Initialize thread
            if (threadProcessor == null)
            {
                threadProcessor                  = new ThreadProcessor();
                threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
                threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_ExecutingStartupType);
                threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_ExecutedStartupType);
            }
            threadProcessor.AsyncRunAllWorkUnits(actions);
        }
Esempio n. 10
0
 private void BeginChangingApplicationPool(List <BaseAction> actions)
 {
     //this.actionableRichTextBox = richTextBoxCreateAppPoolMessage;
     // Initialize thread
     if (threadProcessor == null)
     {
         threadProcessor                  = new ThreadProcessor();
         threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
         threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_Executing);
         threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_Executed);
     }
     ActionFactory.UpdateActions(actions, GetCreateChangeAppPoolParameters());
     threadProcessor.AsyncRunAllWorkUnits(actions);
 }
Esempio n. 11
0
        private void BeginGacing(List <BaseAction> actions)
        {
            this.FormState = FormStateEnum.Processing;


            // Initialize thread
            if (threadProcessor == null)
            {
                threadProcessor                  = new ThreadProcessor();
                threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
                threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_Executing);
                threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_Executed);
            }
            threadProcessor.Run(actions);
        }
Esempio n. 12
0
        private void BeginExecuteActions(List <BaseAction> actions)
        {
            // Change form state
            this.FormState = FormStateEnum.Processing;

            // Initialize thread
            if (threadProcessor == null)
            {
                threadProcessor                  = new ThreadProcessor();
                threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
                threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_ActionExecuting);
                threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_ActionExecuted);
            }
            //threadProcessor.AsyncRun(actions);
            threadProcessor.AsyncRunAllWorkUnits(actions);
        }
Esempio n. 13
0
        private void BeginExecuteActions(List <BaseAction> actions)
        {
            isInterrupted = false;
            // Change form state
            this.FormState = FormStateEnum.Processing;

            // Initialize thread
            if (threadProcessor == null)
            {
                threadProcessor                  = new ThreadProcessor();
                threadProcessor.Completed       += new EventHandler <CompletedEventArgs>(threadProcessor_Completed);
                threadProcessor.ActionExecuting += new EventHandler <ActionExecutingEventArgs>(threadProcessor_ActionExecuting);
                threadProcessor.ActionExecuted  += new EventHandler <ActionExecutedEventArgs>(threadProcessor_ActionExecuted);
            }

            //List<BaseAction> actions = GetCheckedActions();
            ActionFactory.UpdateActions(actions, GetActionParameters());

            //threadProcessor.AsyncRun(actions);
            threadProcessor.AsyncRunWorkUnits(actions);
        }
Esempio n. 14
0
        private void UpdateFormState(FormStateEnum formState)
        {
            switch (formState)
            {
            case FormStateEnum.Initial:
                UpdateCursor(Cursors.Default);
                this.actionableListView = null;
                threadProcessor         = null;
                foreach (TabPage page in tabControlBRE.TabPages)
                {
                    page.Enabled = true;
                }
                break;

            case FormStateEnum.NotProcessing:
                UpdateCursor(Cursors.Default);
                this.actionableListView = null;
                threadProcessor         = null;
                foreach (TabPage page in tabControlBRE.TabPages)
                {
                    page.Enabled = true;
                }
                break;

            case FormStateEnum.Processing:
                UpdateCursor(Cursors.WaitCursor);
                foreach (TabPage page in tabControlBRE.TabPages)
                {
                    if (page != tabControlBRE.SelectedTab)
                    {
                        page.Enabled = false;
                    }
                    else
                    {
                        this.actionableListView = page.Tag as ListView;
                    }
                }
                break;
            }
        }
Esempio n. 15
0
        private void ProcessMessageThread()
        {
            ThreadProcessor.Auto();
            log.InfoFormat("开始对终端消息进行应答处理 {0}", Thread.CurrentThread.ManagedThreadId);
            Tuple <AsyncSocketConnection, TPKGHead> rd = null;
            HiPerfTimer timer = new HiPerfTimer();

            while (_isWorking)
            {
                if (ackQueue.TryDequeue(out rd) == false)//开始从对列中取接收到的数据进行处理
                {
                    Thread.Sleep(50);
                    continue;
                }
                try
                {
                    //服务端

                    timer.Start();
                    FireWaitHandle(rd.Item2);
                    var rs = PacketProcessorManager.DoProcess(rd.Item1, rd.Item2).GetAwaiter().GetResult();
                    if (rd.Item2.Flags.HasFlag(TPKGHeadFlags.CON))
                    {
                        PacketProcessorBase.SendCommonResponseMessage(rd.Item1, rd.Item2, rs == true ? 0 : 1);
                    }
                    timer.Stop();
                    packetCounts.AddOrUpdate(rd.Item2.CommandId, 1, (o, v) => ++ v);
                    packetTime.AddOrUpdate(rd.Item2.CommandId, timer.Duration, (o, v) => v + timer.Duration);
                    packetCounts30s.AddOrUpdate(rd.Item2.CommandId, 1, (o, v) => ++ v);
                    packetTime30s.AddOrUpdate(rd.Item2.CommandId, timer.Duration, (o, v) => v + timer.Duration);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
                Interlocked.Increment(ref processedMessageCount);
            }
        }
Esempio n. 16
0
        private void UpdateFormState(FormStateEnum formState)
        {
            switch (formState)
            {
            case FormStateEnum.Initial:
                UpdateCursor(Cursors.Default);
                contextMenuStrip1.Enabled = true;
                treeView1.Enabled         = true;
                break;

            case FormStateEnum.NotProcessing:
                UpdateCursor(Cursors.Default);
                treeView1.Enabled         = true;
                contextMenuStrip1.Enabled = true;
                threadProcessor           = null;
                break;

            case FormStateEnum.Processing:
                UpdateCursor(Cursors.WaitCursor);
                contextMenuStrip1.Enabled = false;
                treeView1.Enabled         = false;
                break;
            }
        }
Esempio n. 17
0
 void Start()
 {
     Thread_maker = this.GetComponent <ThreadProcessor>();
 }
Esempio n. 18
0
        private void UpdateFormState(FormStateEnum formState)
        {
            switch (formState)
            {
            case FormStateEnum.Initial:

                btnExecute.Visible             = false;
                btnClear.Visible               = false;
                btnStop.Visible                = false;
                btnToggle.Visible              = false;
                cbTargetEnvironment.Enabled    = true;
                cbTargetEnvironment.DataSource = null;
                txtAppName.Text                = string.Empty;
                txtMSILocation.Text            = string.Empty;
                textBoxInstallLocation.Text    = string.Empty;
                rTxtBxMessage.Text             = string.Empty;
                textBoxBTDFProjName.Text       = string.Empty;
                listViewControl.Groups.Clear();
                listViewControl.Items.Clear();
                grpBxMSI.Enabled = true;
                terminateToolStripMenuItem.Enabled  = false;
                saveToFileToolStripMenuItem.Enabled = false;
                DeleteTempBTDFMsiExtractedFolder();
                dataGridView1.Rows.Clear();
                dataGridView1.Refresh();

                checkToolStripMenuItem.Enabled                = false;
                uncheckToolStripMenuItem.Enabled              = false;
                runXSelectedActionsToolStripMenuItem.Enabled  = false;
                runAllCheckedActionsToolStripMenuItem.Enabled = false;

                UpdateCursor(Cursors.Default);
                break;

            case FormStateEnum.End:
                cbTargetEnvironment.Enabled = true;
                UpdateCursor(Cursors.Default);
                btnExecute.Enabled = true;
                btnClear.Enabled   = true;
                threadProcessor    = null;
                grpBxMSI.Enabled   = true;


                CleanTempExtraction();
                break;

            case FormStateEnum.NotProcessing:
                btnToggle.Visible           = true;
                btnStop.Visible             = true;
                btnExecute.Visible          = true;
                btnClear.Visible            = true;
                btnClear.Enabled            = true;
                btnExecute.Enabled          = true;
                cbTargetEnvironment.Enabled = true;
                threadProcessor             = null;
                grpBxMSI.Enabled            = true;

                checkToolStripMenuItem.Enabled                = true;
                uncheckToolStripMenuItem.Enabled              = true;
                runXSelectedActionsToolStripMenuItem.Enabled  = true;
                runAllCheckedActionsToolStripMenuItem.Enabled = true;

                UpdateCursor(Cursors.Default);
                break;

            case FormStateEnum.Processing:
                UpdateCursor(Cursors.WaitCursor);
                btnExecute.Enabled          = false;
                btnClear.Enabled            = false;
                cbTargetEnvironment.Enabled = false;
                grpBxMSI.Enabled            = false;
                break;
            }
        }
Esempio n. 19
0
        private void UpdateFormState(FormStateEnum formState)
        {
            switch (formState)
            {
            case FormStateEnum.Initial:

                applicationStatusToolStripMenuItem.Enabled         = false;
                afterRunApplicationStatusToolStripMenuItem.Enabled = false;
                compareStatusToolStripMenuItem.Enabled             = false;
                btnExecute.Visible           = false;
                btnClear.Visible             = false;
                btnStop.Visible              = false;
                btnToggle.Visible            = false;
                txtMSILocation.Text          = string.Empty;
                txtAppName.Text              = string.Empty;
                txtSSOConfigLoc.Text         = string.Empty;
                txtConfigAppName.Text        = string.Empty;
                chkBxSSOKey.Visible          = false;
                txtBxSSOKey.Visible          = false;
                instancesGridView.DataSource = new DataTable();
                cbTargetEnvironment.Items.Clear();
                threadProcessor = null;
                terminateToolStripMenuItem.Enabled  = false;
                saveToFileToolStripMenuItem.Enabled = false;
                rTxtBxMessage.Text = string.Empty;

                checkToolStripMenuItem.Enabled                = false;
                uncheckToolStripMenuItem.Enabled              = false;
                runXSelectedActionsToolStripMenuItem.Enabled  = false;
                runAllCheckedActionsToolStripMenuItem.Enabled = false;
                generateInstructionsToolStripMenuItem.Enabled = false;
                listViewControl.Items.Clear();
                pictureBox1.Enabled = false;
                UpdateCursor(Cursors.Default);
                break;

            case FormStateEnum.NotProcessing:
                btnToggle.Visible  = true;
                btnStop.Visible    = true;
                btnExecute.Visible = true;
                btnClear.Visible   = true;
                btnClear.Enabled   = true;
                btnExecute.Enabled = true;
                applicationStatusToolStripMenuItem.Enabled         = true;
                afterRunApplicationStatusToolStripMenuItem.Enabled = true;
                compareStatusToolStripMenuItem.Enabled             = true;
                checkToolStripMenuItem.Enabled                = true;
                uncheckToolStripMenuItem.Enabled              = true;
                runXSelectedActionsToolStripMenuItem.Enabled  = true;
                runAllCheckedActionsToolStripMenuItem.Enabled = true;
                generateInstructionsToolStripMenuItem.Enabled = true;
                rTxtBxMessage.Text  = string.Empty;
                pictureBox1.Enabled = true;
                threadProcessor     = null;
                swinstancesAction.Stop();
                UpdateCursor(Cursors.Default);
                break;

            case FormStateEnum.Processing:
                btnExecute.Enabled = false;
                btnClear.Enabled   = false;
                UpdateCursor(Cursors.WaitCursor);
                break;
            }
        }
        public bool Enqueue(T item)
        {
            var r = false;
            var reThrowException = false;

            var enabledCountPerformance = true;

            if (_onEnabledCountPerformanceProcessFunc != null)
            {
                enabledCountPerformance = _onEnabledCountPerformanceProcessFunc();
            }

            var qpcc = PerformanceCountersContainer;

            PerformanceCountersHelper
            .TryCountPerformance
            (
                () =>
            {
                return(enabledCountPerformance);
            }
                , reThrowException
                , qpcc
                .IncrementCountersBeforeCountPerformanceForEnqueue
                //incrementCountersBeforeCountPerformance
                , null
                , null
                , () =>
            {
                Stopwatch stopwatchEnqueue = null;
                if (_isAttachedPerformanceCounters)
                {
                    _stopwatchsPool.TryGet(out stopwatchEnqueue);
                }
                stopwatchEnqueue.Start();
                var element = Tuple
                              .Create
                              (
                    stopwatchEnqueue
                    , item
                              );
                _queue.Enqueue(element);
                r = true;
            }
                , (x, y, z) =>
            {
                qpcc
                .CaughtExceptionsPerformanceCounter
                .Increment();
                if (OnEnqueueProcessCaughtException != null)
                {
                    reThrowException = OnEnqueueProcessCaughtException(this, x, y, z);
                }
                if (!reThrowException)
                {
                    if (OnCaughtException != null)
                    {
                        reThrowException = OnCaughtException(this, x, y, z);
                    }
                }
                return(reThrowException);
            }
                , (x, y, z, w) =>
            {
                if
                (
                    _waitingDequeueThreadsProcessorsStack != null &&
                    _waitingDequeueThreadsProcessorsStack.Count > 0
                )
                {
                    ThreadProcessor processor = null;
                    if
                    (
                        _waitingDequeueThreadsProcessorsStack
                        .TryPop(out processor)
                    )
                    {
                        processor.Waiter.Set();
                        processor = null;
                        //Console.WriteLine("processor = null; {0}", _waitingDequeueThreadsProcessorsStack.Count);
                    }
                }
            }
            );
            return(r);
        }
Esempio n. 21
0
 public void EndExecuteActions()
 {
     this.FormState  = FormStateEnum.NotProcessing;
     threadProcessor = null;
 }