using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace IReaper.Statues{
public partial class AsyncWork : BackgroundWorker
{
IiReaperStatusStrip status;
string message;
static IiReaperStatusStrip emptyStatus = new EmptyStatusStrip();
public AsyncWork()
{
InitializeComponent();
}
public AsyncWork(IContainer container)
{
container.Add(this);
InitializeComponent();
}
/// <summary>
/// AsyncWorkiReaperStatusStrip
/// </summary>
public new void RunWorkerAsync()
{
if(iReaperStatusStrip.statuStripInstance != null)
{
iReaperStatusStrip.statuStripInstance.BeginAsyncWork(this);
}
else
{
base.RunWorkerAsync(this);
}
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnDoWork(DoWorkEventArgs e)
{
base.OnDoWork(e);
this.status = e.Argument as IiReaperStatusStrip;
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnProgressChanged(ProgressChangedEventArgs e)
{
if (this.status != null)
{
this.status.TaskMessage = this.Message;
this.status.Percentage = e.ProgressPercentage;
}
base.OnProgressChanged(e);
}
protected override void OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
{
base.OnRunWorkerCompleted(e);
//5
if (this.status != null)
{
this.status.TaskMessage = "";
this.status.Percentage = 0;
}
}
/// <summary>
///
/// </summary>
[Browsable(false)]
protected string Message
{
get { return message; }
set { message = value; }
}
[Browsable(false)]
internal IiReaperStatusStrip Status
{
get { return status; }
}
}
}
|