日期:2014-05-17 浏览次数:20851 次
//操作类内
namespace SocketDebugTool
{
public delegate void UpdateListview(string str);
class ClientTcp
{
public event UpdateListview updatelistview;
………………………………
/// <summary>
/// 开始
/// </summary>
public void start()
{
worker = new BackgroundWorker();
// 设置可以取消
worker.WorkerSupportsCancellation = true;
// 设置可以通告进度
//worker.WorkerReportsProgress = true;
//处理过程
worker.DoWork += new DoWorkEventHandler(doWork);
//更新控件
//worker.ProgressChanged += new ProgressChangedEventHandler(UpdateProgress);
//当后台操作已完成、被取消或引发异常时发生
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedWork);
//go
worker.RunWorkerAsync();
}
private void doWork(object sender, DoWorkEventArgs e)
{
…………
for (int i = count; i > 0 && run; --i)
{
………………
if (……)
{
……
&