110,561
社区成员
发帖
与我相关
我的任务
分享
while (bRet) //开始下载=================================================
{
nRet = Online_StLoad(PCommData, 0, ref nTLength, ref nSLength); //下载文件
if (nRet > 2) { bRet = false; break; }
if (ProgressEvent != null) //进度指示处理
{
try
{
if (nTLength <= 0) nTLength = 0;
if (nSLength <= 0) nSLength = nTLength;
if (nSLength <= 0) nPercent = 100;
else nPercent = (uint)((nTLength * 100) / nSLength);
MultiEjOnlineProgressEventArgs e = new MultiEjOnlineProgressEventArgs(SFile, nPercent);
if (e != null)
{
ProgressEvent(sender, e);
if (e.Cancel) { bRet = false; bCb = true; }
}
}
catch
{ bRet = false; }
}
if (!bRet || nRet == 2) break; //如果回调返回FALSE值,则终止函数的执行
Thread.Sleep((int)Esctime);
}
if (bCb == true)
Online_ESC_z(PCommData, Address);
Online_StLoad(PCommData, 1, ref nTLength, ref nSLength); //停止下载=================================================
public class MultiEjOnlineProgressEventArgs : System.EventArgs
{
/// <summary> 用于保存事件信息 </summary>
private string FMessage = string.Empty;
/// <summary> 用于保存百分比值 </summary>
private uint FPercent = 0;
/// <summary> 用于执行状态值 </summary>
private bool FCancel = false;
public MultiEjOnlineProgressEventArgs(string Message, uint Percent) //构造函数
{
if(Message == null)
FMessage = string.Empty;
else
FMessage = Message;
FPercent = Percent;
FCancel = false;
}
public string Message //获取事件信息
{
get
{ return FMessage; }
}
public uint Percent //获取百分比值
{
get
{ return FPercent; }
}
public bool Cancel //获取/设置执行状态
{
get
{ return FCancel; }
set
{ FCancel = value; }
}
}