如何使用进度条从线程获取retun值 [英] how to get the retun value from thread using progress bar

查看:141
本文介绍了如何使用进度条从线程获取retun值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用

进度条

 thread 

从数据库下载数据并将其转换为表格。当 thread 完成表将下载的工作时。

i在线程进程的下载表中有问题。



如何从线程中获取输出





  protected   void  btnStart_Click( object  sender,EventArgs e) 
{
StringBuilder threadBuilder = new StringBuilder();
ProgressBar1.Visible = true ;
pReadytoDown.Visible = true ;
进度进度= ProgressBar1.Progress;
线程thread = new 线程(()= > {threadBuilder =开始(进度) ;
< big> _builder < / big > = threadBuilder;

});
thread.Start();
btnStart.Enabled = false ;

// ProgressBar1.Completed = false;
}



我用全局静态变量来解决这个问题



谢谢

解决方案

  protected   void  btnStart_Click( object  sender,EventArgs e)
{
StringBuilder threadBuilder = new StringBuilder();
ProgressBar1.Visible = true ;
pReadytoDown.Visible = true ;
进度进度= ProgressBar1.Progress;
线程thread = new 线程(()= {threadBuilder =开始(进度);
_builder = threadBuilder;

});
thread.Start();
btnStart.Enabled = false ;

// ProgressBar1.Completed = false;
}





答案有问题。

从线程聚焦方法返回值简单。

threadBuilder 是返回值

i'm using the

progress bar

in my application.

thread

download the data from database and it's convert into table. when thread finish the work that table will download.
i have an issue in download table from thread process.

how to get the output from the thread


protected void btnStart_Click(object sender, EventArgs e)
   {
       StringBuilder threadBuilder = new StringBuilder();
       ProgressBar1.Visible = true;
       pReadytoDown.Visible = true;
       Progress progress = ProgressBar1.Progress;
       Thread thread = new Thread(() => { threadBuilder = Start(progress);
      <big> _builder</big> = threadBuilder;

       });
       thread.Start();
       btnStart.Enabled = false;

       //ProgressBar1.Completed = false;
   }


i'm used the global static variable to solve this problem

thank you

解决方案

protected void btnStart_Click(object sender, EventArgs e)
   {
       StringBuilder threadBuilder = new StringBuilder();
       ProgressBar1.Visible = true;
       pReadytoDown.Visible = true;
       Progress progress = ProgressBar1.Progress;
       Thread thread = new Thread(() = { threadBuilder= Start(progress);
       _builder = threadBuilder;

       });
       thread.Start();
       btnStart.Enabled = false;

       //ProgressBar1.Completed = false;
   }



answer is in ques.
return the value from the thread focusing method simple.
threadBuilder is the return value


这篇关于如何使用进度条从线程获取retun值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆