标签:oid 文件 sop 还需 += 使用 mount 文件的 注意
#region 删除垃圾文件过程
/// <summary>
/// 删除垃圾文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_delete_Click(object sender, EventArgs e)
{
//开启后台查询线程,即引发新线程的事件,同时提供事件参数
//注意backgroundWork中的DoWork事件,并编写事件处理程序,
//并提供事件数据,因为后台线程是无法直接访问主线程的数据的,
//同时还需要编写backgroundWork中的RunWorkerCompleted事件处理程序,
//以通知前端主线程
string doWorkArguments = cmb_fileFolderDerectory.Text;
backgroundWorker1.RunWorkerAsync(doWorkArguments);
//开启处理进程条
this.progressBar1.Visible = true;
timer1.Interval = 100;
this.timer1.Tick += new EventHandler(Timer1_Tick);
timer1.Start();
}
/// <summary>
/// 用计时器体现查询进度表,非真实进度,仅是对用户的提示,因后台查询进度暂无法计算衡量
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Timer1_Tick(object sender, EventArgs e)
{
if (!finishedFlag)
{
if (progressBar1.Value == progressBar1.Maximum)
{
progressBar1.Value = 1;
}
else
{
this.progressBar1.Value++;
}
}
else
{
this.timer1.Stop();
}
}
/// <summary>
/// 删除文件的后台进程
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
FilesOperate f = new FilesOperate();
int deleteFilesAmount = f.DeleteUserFile(e.Argument.ToString());
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.finishedFlag = true;
//完成后进程条不可见
this.progressBar1.Visible = false;
MessageBox.Show("删除垃圾文件" + this.deleteFilesAmount + "个", "删除提示");
}
#endregion
标签:oid 文件 sop 还需 += 使用 mount 文件的 注意
原文地址:https://www.cnblogs.com/windy3417/p/14122753.html