catch (Exception er)
{
MessageBox.Show (er.Message );
}
// 接收线程数
thread=Convert.ToInt32 (textBox4.Text .Trim().ToString (),10);
//根据线程数初始化数组
threadw=new bool [thread];
filenamew=new string [thread];
filestartw=new int [thread];
filesizew=new int[thread]
//计算每个线程应该接收文件的大小
int filethread=(int)filesize/thread;//平均分配
int filethreade=filethread+(int)filesize%thread;//剩余部分由最后一个线程完成
//为数组赋值
for (int i=0;i
{
threadw[i]=false;//每个线程状态的初始值为假
filenamew[i]=i.ToString ()+".dat";//每个线程接收文件的临时文件名
if (i
{
filestartw[i]=filethread*i;//每个线程接收文件的起始点
filesizew[i]=filethread-1;//每个线程接收文件的长度
}
else
{
filestartw[i]=filethread*i;
filesizew[i]=filethreade-1;
}
}
//定义线程数组,启动接收线程
Thread[] threadk=new Thread [thread];
HttpFile[] httpfile=new HttpFile [thread];
for (int j=0;j
{
httpfile[j]=new HttpFile(this,j);
threadk[j]=new Thread(new ThreadStart (httpfile[j].receive ));
threadk[j].Start ();
}
//启动合并各线程接收的文件线程
Thread hbth=new Thread (new ThreadStart (hbfile));
hbth.Start ();
}
{
MessageBox.Show (er.Message );
}
// 接收线程数
thread=Convert.ToInt32 (textBox4.Text .Trim().ToString (),10);
//根据线程数初始化数组
threadw=new bool [thread];
filenamew=new string [thread];
filestartw=new int [thread];
filesizew=new int[thread]
//计算每个线程应该接收文件的大小
int filethread=(int)filesize/thread;//平均分配
int filethreade=filethread+(int)filesize%thread;//剩余部分由最后一个线程完成
//为数组赋值
for (int i=0;i
{
threadw[i]=false;//每个线程状态的初始值为假
filenamew[i]=i.ToString ()+".dat";//每个线程接收文件的临时文件名
if (i
{
filestartw[i]=filethread*i;//每个线程接收文件的起始点
filesizew[i]=filethread-1;//每个线程接收文件的长度
}
else
{
filestartw[i]=filethread*i;
filesizew[i]=filethreade-1;
}
}
//定义线程数组,启动接收线程
Thread[] threadk=new Thread [thread];
HttpFile[] httpfile=new HttpFile [thread];
for (int j=0;j
{
httpfile[j]=new HttpFile(this,j);
threadk[j]=new Thread(new ThreadStart (httpfile[j].receive ));
threadk[j].Start ();
}
//启动合并各线程接收的文件线程
Thread hbth=new Thread (new ThreadStart (hbfile));
hbth.Start ();
}