本文整理汇总了C#中DoWorkEventHandler类的典型用法代码示例。如果您正苦于以下问题:C# DoWorkEventHandler类的具体用法?C# DoWorkEventHandler怎么用?C# DoWorkEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoWorkEventHandler类属于命名空间,在下文中一共展示了DoWorkEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadMediaInfoWorker
internal UploadMediaInfoWorker(FileInfo inputFile)
{
Logger.Info("Starting new UploadMediaInfoWorker on " + inputFile.FullName);
this.inputFile = inputFile;
DoWork += new DoWorkEventHandler(UploadMediaInfoWorker_DoWork);
}
示例2: ProcessBackground
public ProcessBackground(int Max, DoWorkEventHandler DoWork, ProgressChangedEventHandler worker_ProgressChanged)//最大值和标题
{
progressForm = new FrmAutoUpdate();
progressForm.progressBarDownload.Value = 0;
progressForm.Show();
SetbackgroundWorker(DoWork, worker_ProgressChanged);
}
示例3: BackgroundConnectionHelper
public BackgroundConnectionHelper(DoWorkEventHandler AsyncDelegate, RunWorkerCompletedEventHandler GUIDelegate)
{
backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += AsyncDelegate;
backgroundWorker.RunWorkerCompleted += GUIDelegate;
backgroundWorker.WorkerSupportsCancellation = true;
}
示例4: runAsyncLoadingAction
/// <summary>
/// Shows loading form and executes given action as async background worker.
/// </summary>
/// <param name="action">Async action to execute</param>
/// <param name="Text">Text to display on loading form</param>
/// <param name="invertOrder">true - action will be runned first, loading form will be showed as second action | false - first will be showed loading form, second will be executed given action</param>
/// <param name="sleep">delay in ms to wait between given action and loading form showing</param>
public void runAsyncLoadingAction(DoWorkEventHandler action, String Text, bool invertOrder = false, int sleep=0)
{
this.Enabled = false;
loadingText = Text;
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler(handleLoading);
BackgroundWorker bw2 = new BackgroundWorker();
if (action != null)
{
bw2.DoWork += new DoWorkEventHandler(action);
bw2.RunWorkerCompleted += handleLoadingEnd;
}
if (!invertOrder)
{
if (action != null)
{
bw2.RunWorkerAsync();
if (sleep>0)
System.Threading.Thread.Sleep(sleep);
}
bw.RunWorkerAsync();
}
else {
bw.RunWorkerAsync();
if (action != null)
{
if (sleep>0)
System.Threading.Thread.Sleep(sleep);
bw2.RunWorkerAsync();
}
}
}
示例5: ProgressDialog
/// <summary>
/// ProgressDialogクラスのコンストラクタ
/// </summary>
/// <param name="caption">タイトルバーに表示するテキスト</param>
/// <param name="doWorkHandler">バックグラウンドで実行するメソッド</param>
/// <param name="argument">doWorkで取得できるパラメータ</param>
public ProgressDialog(string caption,
DoWorkEventHandler doWork,
object argument)
{
InitializeComponent();
//初期設定
this.workerArgument = argument;
this.Text = caption;
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.ShowInTaskbar = false;
this.StartPosition = FormStartPosition.CenterParent;
this.ControlBox = false;
this.CancelButton = this.cancelAsyncButton;
this.messageLabel.Text = "";
this.progressBar1.Minimum = 0;
this.progressBar1.Maximum = 100;
this.progressBar1.Value = 0;
this.cancelAsyncButton.Text = "キャンセル";
this.cancelAsyncButton.Enabled = true;
this.backgroundWorker1.WorkerReportsProgress = true;
this.backgroundWorker1.WorkerSupportsCancellation = true;
//イベント
this.Shown += new EventHandler(ProgressDialog_Shown);
this.cancelAsyncButton.Click += new EventHandler(cancelAsyncButton_Click);
this.backgroundWorker1.DoWork += doWork;
this.backgroundWorker1.ProgressChanged +=
new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
this.backgroundWorker1.RunWorkerCompleted +=
new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
}
示例6: AsyncWorker
/// <summary>
/// Initializes a new instance of the <see cref="AsyncWorker"/> class.
/// </summary>
/// <param name="name">The name used in log messages.</param>
/// <param name="worker">The worker delegate.</param>
/// <param name="completed">The completed delegate.</param>
public AsyncWorker(
string name,
DoWorkEventHandler worker,
RunWorkerCompletedEventHandler completed)
: this(name, worker, null, completed)
{
}
示例7: FormInfo
public FormInfo(Form owner,
string Message,
DoWorkEventHandler DoWork,
RunWorkerCompletedEventHandler RunWorkerCompleted)
{
doInitialize(owner, Message, DoWork, RunWorkerCompleted, null);
}
示例8: RegisterDoWork
private static void RegisterDoWork(this BackgroundWorker bw, DoWorkEventHandler doWorkEvent = null)
{
bw.WorkerSupportsCancellation = true;
//默认实现
if (doWorkEvent == null)
{
doWorkEvent = (sender, e) =>
{
var ce = e.Argument as CustomerDoWorkEventArgs;//获取传递参数
BackgroundWorker cBw = ce.ExecBackgroundWorker;
int count = Convert.ToInt32(ce.ExecParameter.ToString(), 10);
for (int i = 0; i < count; i++)
{
if (!cBw.CancellationPending)//永远可以取消
{
//汇报当前处理进度
cBw.ReportProgress(i, "正在处理第" + i + "条数据");
Thread.Sleep(500);
}
else
{
e.Cancel = true;
return;
}
}
e.Result = "执行操作完成的结果:1";
};
}
bw.DoWork += doWorkEvent;
}
示例9: QBDepositWorker
public QBDepositWorker(DailyDeposit dailyDeposit)
{
_dailyDeposit = dailyDeposit;
DoWork += new DoWorkEventHandler(QBDepositWorker_DoWork);
WorkerReportsProgress = true;
WorkerSupportsCancellation = true;
}
示例10: WorkerHelper
/// <summary>
/// Constructor that accepts Event handlers for executing async thread
/// </summary>
/// <param name="WorkerProcess">Worker Process Handler</param>
/// <param name="WorkProgressHandler">Progress Changed Event Handler</param>
/// <param name="WorkCompletedHandler">Call back method handler which is invoked once the Worker Process is completed</param>
public WorkerHelper(DoWorkEventHandler WorkerProcess, ProgressChangedEventHandler WorkProgressHandler, RunWorkerCompletedEventHandler WorkCompletedHandler)
{
this.DoWork += WorkerProcess;
this.ProgressChanged += WorkProgressHandler;
this.RunWorkerCompleted += WorkCompletedHandler;
this.WorkerReportsProgress = true;
}
示例11: ConsoleWorker
public ConsoleWorker(int maximumCount)
{
_countProtector = new Object();
_maxCount = maximumCount;
_workerCallback = new AsyncCallback(this.OnRunWorkerCompleted);
_eventHandler = new DoWorkEventHandler(this.OnDoWork);
}
示例12: InitNewBackgroundWorker
public static BackgroundWorker InitNewBackgroundWorker(DoWorkEventHandler doWorkEvent, ProgressChangedEventHandler progressChangedEvent, RunWorkerCompletedEventHandler runWorkerCompletedEvent)
{
var bw = new BackgroundWorker();
bw.RegisterDoWork(doWorkEvent);
bw.RegisterProgressChanged(progressChangedEvent);
bw.RegisterRunWorkerCompleted(runWorkerCompletedEvent);
return bw;
}
示例13: PublishWorkerHost
internal PublishWorkerHost(string outputDirectoryPath)
{
DoWork += new DoWorkEventHandler(SaveWorkerHost_DoWork);
WorkerReportsProgress = true;
WorkerSupportsCancellation = true;
this.outputDirectoryPath = outputDirectoryPath;
}
示例14: RunBackground
private void RunBackground(DoWorkEventHandler doWork, object argument, RunWorkerCompletedEventHandler runWorkerCompleted)
{
using (BackgroundWorker backgroundWorker = new BackgroundWorker())
{
backgroundWorker.DoWork += doWork;
backgroundWorker.RunWorkerCompleted += runWorkerCompleted;
backgroundWorker.RunWorkerAsync(argument);
}
}
示例15: startWork
public void startWork(DoWorkEventHandler work, String description)
{
if (bg_worker.IsBusy) return;
isProgressBarActive = true;
StatusText = description;
bg_worker.DoWork += work;
bg_worker.RunWorkerAsync();
bg_worker.DoWork -= work;
}