using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.ComponentModel;
namespace IReaper.Command{
abstract class CommandBase
{
public event EventHandler OnWorkerComplete;
/// <summary>
/// Command
/// </summary>
/// <param name="sender">Command</param>
/// <param name="paras">Command</param>
public abstract void CommandBody(object sender,params object[] paras);
public void ExecuteAsync(object sender, params object[] paras)
{
ThreadStart start = new ThreadStart(delegate()
{
this.CommandBody(sender, paras);
});
start.BeginInvoke(null, null);
}
public void Execute(object sender, params object[] paras)
{
this.CommandBody(sender, paras);
}
public abstract CommandFamily Family
{ get;}
protected void BindBackgroundWorker(BackgroundWorker worker)
{
if (null == worker)
{
return;
}
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(delegate
{
if (OnWorkerComplete != null)
{
OnWorkerComplete(this, EventArgs.Empty);
}
});
}
}
}
|