zoukankan      html  css  js  c++  java
  • C# WinForm 弹出模式窗口操作滚动条

    弹出的模式窗体

    public partial class frmProcessBar : Form
    {
        public frmProcessBar()
        {
            InitializeComponent();
        }
        
        public bool Increase(int runTime)
        {
            if (runTime > 0)
            {
                int tempTime = Convert.ToInt32(prcBar.Value);
                if (tempTime % 10 == 0)
                {
                    this.labTimer.Text = (Convert.ToInt32(this.labTimer.Text) + runTime).ToString();
                }
                if (prcBar.Value + runTime < prcBar.Maximum)
                {
                    prcBar.Value += runTime;
                    return true;
                }else{
                    prcBar.Value = prcBar.Maximum;
                    this.Close();
                    return false;
                }
            }
            return false;
        }
    }

    测试用例

    public delegate string AsyncMethodCaller();
    public delegate void AsyncShowMethod();
    private frmProcessBar myProcessBar = null;
    private delegate bool IncreaseHandle(int runTime);
    private IncreaseHandle myIncrease = null;
    
    private void ShowProcessBar()
    {
        myProcessBar = new frmProcessBar();
        myIncrease = new IncreaseHandle(myProcessBar.Increase);
        myProcessBar.StartPosition = FormStartPosition.CenterParent;
        myProcessBar.ShowDialog();
        myProcessBar = null;
    }
    
    string result = string.Empty;//接收返回的结果
    AsyncMethodCaller callerRun = new AsyncMethodCaller(disPlay.Show); //耗时执行的方法
    IAsyncResult synresult = callerRun.BeginInvoke(null, null);
    this.BeginInvoke(new AsyncShowMethod(ShowProcessBar)); //启动弹出窗体
    while (synresult.IsCompleted == false)
    {
        this.BeginInvoke(this.myIncrease, new object[] { 1, 1 });
        Thread.Sleep(100);
    }
    this.BeginInvoke(this.myIncrease, new object[] { 100, 1 });
    result = callerRun.EndInvoke(synresult); // 返回执行的结果
  • 相关阅读:
    思路决定出路
    php-异常处理机制
    Win10 IoT 10 中文显示乱码或报错的问题
    Win10 IoT 9 Windows IoT Core扩展开发包
    Win10 IoT 8 GPIO输入输出
    Win10 IoT 7 10586版本的异同
    Win10 IoT 6 设置系统时间
    Win10 IoT 5 修改IP地址
    Win10 IoT 4 远程启动计划任务
    Win10 IoT 3 部署应用
  • 原文地址:https://www.cnblogs.com/rinack/p/2708099.html
Copyright © 2011-2022 走看看