zoukankan      html  css  js  c++  java
  • windows mobile多线程示例

    AuthorQuietwalk

    Date2010-10-9

     

    private static bool bThreadEnd;

    private Thread workThread;

    DateTime dtStart;

    DateTime dtEnd;

     

      #region download

            private void miDownLoad_Click(object sender, EventArgs e)

            {

                this.btnSend.Visible = false;

                this.btnReceiveFile.Visible = true; //使能下载按钮

                this.btnReceiveFile.Focus();

                this.statusBar1.Text = "";

            }

            //下载并接收文件

            //调用WebService 将应用服务器上的 Zip 包转换成二进制流发送出来

            //调用设备本地的代码接收并存放

            private void btnReceiveFile_Click(object sender, EventArgs e)

            {

              

                //*******************************************

                this.timer1.Enabled = true;

                this.btnReceiveFile.BackColor = Color.Yellow;

                this.statusBar1.Text = "正在下载数据,请稍候。。。";

                dtStart = DateTime.Now;

                workThread = new Thread(new ThreadStart(ReceiveAndSaveFile));

                workThread.Start();

     

           

            }

     

            private void ReceiveAndSaveFile()

            {

     

                bThreadEnd = false;

                GPRSTest.jwsHelloWorld.HelloWordImplService sv = new HelloWordImplService();

                QuietwalkClassLibrary.CommonFunctions.SaveFile(sv.convertZip2ByteArray());//返回的是执行后成功与否,但这里不需要接收此参数

     

                bThreadEnd = true;

            }

     

            private void timer1_Tick(object sender, EventArgs e)

            {

               

                if (!bThreadEnd)//如果线程没有结束

                {

                    if (this.progressBar1.Value == progressBar1.Maximum)//到最大了之后再从0开始

                    {

                        this.progressBar1.Value = 0;

                    }

     

                    this.progressBar1.Value += 5;

     

                 

                }

                else//线程结束了

                {

                    this.timer1.Enabled = false;//关闭计时器

                    this.progressBar1.Value = this.progressBar1.Maximum;

     

                    dtEnd = DateTime.Now;

     

                    if (QuietwalkClassLibrary.CommonFunctions.bDoneStatus)

                    {

                        this.statusBar1.Text = this.statusBar1.Text = "下载并存储到设备所用时间:  " + QuietwalkClassLibrary.CommonFunctions.GetTimeSpan(dtStart, dtEnd).ToString() + "--" + DateTime.Now.ToShortTimeString();

                    }

                    else

                    {

                        this.statusBar1.Text = "下载失败!";

                    }

                   

                  

     

                }

     

            }

            #endregion download

  • 相关阅读:
    网页速度分析:PageSpeed Insights (by Google)
    Win10下Jenkins服务是系统账户导致无法使用用户的私有环境变量
    部署Pod非Running状态,describe查看显示node资源不足
    kubernetes部署Pod一直处于CrashLookBackOff状态
    kubernetes部署的Pod长时处于ContainerCreating状态
    VMWARE用OVF文件方式导入报错:Error importing OVF: Failed to open disk: /var/lib/docker/vmwareOVF/Centos_7_64-bit-disk2.vmdk. Reason: The file specified is not a virtual disk
    VMWARE用OVF文件方式导入报错:Error importing OVF:SHA digest of file CentOS_7_64-bit-file1iso does not match manifest
    Linux系统ssh到其它服务器时间延迟长
    Linux系统服务器重启后进入到急救模式
    linux系统内存使用率飙高到90%
  • 原文地址:https://www.cnblogs.com/quietwalk/p/1846457.html
Copyright © 2011-2022 走看看