当前位置: 首页>>代码示例>>C#>>正文


C# System.Threading.Thread.Interrupt方法代码示例

本文整理汇总了C#中System.Threading.Thread.Interrupt方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Thread.Interrupt方法的具体用法?C# System.Threading.Thread.Interrupt怎么用?C# System.Threading.Thread.Interrupt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Thread的用法示例。


在下文中一共展示了System.Threading.Thread.Interrupt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ElementFireEvent

        public void ElementFireEvent(IdentifierType identType, string identifier, string tagName, string eventName)
        {
            isBrowserAccessible();

            waitForBrowser();
            IHTMLElement3 elem = (IHTMLElement3)getElement(identType, identifier, tagName);
            _eventInfo = new ElementEventInfo();

            //if (isParent && eventName.Equals("onclick") && !identifier.Contains(";"))
            //{
            //    searchedParent = true;
            //    isParent = false;
            //    //multiple casting to make sure it will perform the even on the first child found
            //    if (elem is HTMLDivElement)
            //    {
            //        IHTMLElement3 childElem = (IHTMLElement3)(((HTMLDivElement)elem).firstChild);
            //        _eventInfo.elem = childElem;
            //        _eventInfo.eventName = eventName;
            //    }
            //    else if (elem is HTMLTableCellClass)
            //    {
            //        IHTMLElement3 childElem = (IHTMLElement3)(((HTMLTableCell)elem).firstChild);
            //        _eventInfo.elem = childElem;
            //        _eventInfo.eventName = eventName;
            //    }
            //    else if (elem is HTMLAnchorElement)
            //    {
            //        IHTMLElement3 childElem = (IHTMLElement3)(((HTMLAnchorElement)elem).firstChild);
            //        _eventInfo.elem = childElem;
            //        _eventInfo.eventName = eventName;
            //    }
            //}
            //else
            //{
            //    isParent = false;
            //    _eventInfo.elem = elem;
            //    _eventInfo.eventName = eventName;
            //}

            _eventInfo.elem = elem;
            _eventInfo.eventName = eventName;
            toggleElementColor((IHTMLElement)elem);
            System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(fireTheEvent));
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();

            //When debugging you can increase this time so the thread doesn't stop before you step into fireTheEvent
            //t.Join(20000);
            t.Join(2000);

            if (_eventInfo.exception != null)
            {
                throw new StimulateElementException(identifier, eventName);
            }

            if (t.IsAlive)
                t.Interrupt();

            // Give the operating system time in case our stimulate element caused the window to close
            Sleep(100);
        }
开发者ID:dineshkummarc,项目名称:SWAT_4.1_Binaries_Source,代码行数:61,代码来源:InternetExplorer.cs

示例2: btnListTelemetryUpdates_Click

        private void btnListTelemetryUpdates_Click(object sender, EventArgs e)
        {
            disableListActionButtons();
            //initialize class for installed updates according to menu selection
            InstalledUpdatesBase instUpdates = null;
            if (tsmiUpdateHistory.Checked)
                instUpdates = new InstalledUpdatesHistory();
            else
                instUpdates = new InstalledUpdatesWMIC();

            toolStripProgressBarMain.Style = ProgressBarStyle.Marquee;
            toolStripProgressBarMain.Visible = true;
            tsslMain.Text = "Searching for installed telemetry updates...";

            bool enableUninstallButton = false;

            int i = 0;
            for (i = 0; i < m_dataKB.Count; ++i)
            {
                if (instUpdates.isInstalledByKBNumber(m_dataKB[i].KB))
                {
                    dgvTelemetryUpdates.Rows[i].Cells[idxInstalled].Value = "YES";
                    dgvTelemetryUpdates.Rows[i].Cells[idxInstalled].Style.BackColor = System.Drawing.Color.LightSalmon;
                    enableUninstallButton = true;
                }
                else
                {
                    dgvTelemetryUpdates.Rows[i].Cells[idxInstalled].Value = "no";
                    dgvTelemetryUpdates.Rows[i].Cells[idxInstalled].Style.BackColor = System.Drawing.Color.LightGreen;
                }
            } //for
            instUpdates = null;

            //Allow application to redraw the data grid view with current data.
            Application.DoEvents();

            //Search for hidden updates - this takes a while.
            tsslMain.Text = "Searching for blocked telemetry updates...";
            m_syncList = null;

            System.Threading.Thread worker = new System.Threading.Thread(threadedListProc);
            worker.Start();
            while (!worker.Join(400))
            {
                //Process application events.
                Application.DoEvents();
            } //while
            try
            {
                worker.Interrupt();
            }
            catch (Exception)
            {
                // Do nothing.
            }

            if (null == m_syncList)
                m_syncList = new List<UpdateInfo>();
            List<UpdateInfo> hiddenStuff = m_syncList;
            for (i = 0; i < m_dataKB.Count; ++i)
            {
                bool found = false;
                foreach (UpdateInfo update in hiddenStuff)
                {
                    if (update.KBArticleIDs.Contains(m_dataKB[i].KB.ToString()))
                    {
                        found = true;
                        break; //break out of inner loop (foreach)
                    } //if
                } //foreach
                if (found)
                {
                    dgvTelemetryUpdates.Rows[i].Cells[idxBlocked].Value = "yes";
                    dgvTelemetryUpdates.Rows[i].Cells[idxBlocked].Style.BackColor = System.Drawing.Color.LightGreen;
                }
                else
                {
                    dgvTelemetryUpdates.Rows[i].Cells[idxBlocked].Value = "NO";
                    dgvTelemetryUpdates.Rows[i].Cells[idxBlocked].Style.BackColor = System.Drawing.Color.LightSalmon;
                    enableUninstallButton = true;
                }
            } //for

            tsslMain.Text = "Status: None";
            toolStripProgressBarMain.Style = ProgressBarStyle.Blocks;
            toolStripProgressBarMain.Visible = false;

            btnUninstall.Enabled = enableUninstallButton;

            enableListActionButtons();
        }
开发者ID:striezel,项目名称:telemetry-update-removal,代码行数:91,代码来源:FormMain.cs


注:本文中的System.Threading.Thread.Interrupt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。