threadmsgmonitor.cs

来自「用C#编写的一个款搜索engine的源代码!摘自<Visual c#200」· CS 代码 · 共 81 行

CS
81
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SECompare.Structure;

namespace SECompare.Controls
{
    public partial class ThreadMsgMonitor : UserControl
    {
        public ThreadMsgMonitor()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Title which is displayed on the top of the control.
        /// </summary>
        public String Title
        {
            set
            {
                this.lblTitle.Text = value;
            }
        }

        /// <summary>
        /// Set the thread to run and controlled by the panel.
        /// </summary>
        public ThreadStatus ThreadStatus
        {
            set
            {
                this.m_ThreadStatus = value;
            }
        }
        private ThreadStatus m_ThreadStatus;        //Thread controller

        /// <summary>
        /// Set the button which starts the process.
        /// </summary>
        public System.Windows.Forms.Button StartButton
        {
            set
            {
                this.m_StartButton = value;
            }
        }
        private System.Windows.Forms.Button m_StartButton;

        public void Start()
        {
            this.timer.Start();
            this.m_StartButton.Enabled = false;
        }

        public void Stop()
        {
            this.timer.Stop();
            this.m_StartButton.Enabled = true;
        }

        private void timer_Tick(object sender, System.EventArgs e)
        {
            if (this.m_ThreadStatus == null)
                return;

            if (this.m_ThreadStatus.IsFinished == false)
                this.lblMsg.Text = this.m_ThreadStatus.Status;
            else
            {
                this.Stop();
                MessageBox.Show("Task [" + this.lblTitle.Text + "] Completed!", "Task Completed");
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?