本文整理汇总了C#中RunWorkerCompletedEventHandler类的典型用法代码示例。如果您正苦于以下问题:C# RunWorkerCompletedEventHandler类的具体用法?C# RunWorkerCompletedEventHandler怎么用?C# RunWorkerCompletedEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RunWorkerCompletedEventHandler类属于命名空间,在下文中一共展示了RunWorkerCompletedEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: pgWorker
public pgWorker(int pos, string dsn,
ProgressChangedEventHandler onProgress,
RunWorkerCompletedEventHandler onComplete)
{
this.thNo = pos;
this.pg_conn = new NpgsqlConnection(dsn);
try
{
pg_conn.Open();
pg_error = "";
}
catch (Exception ex)
{
pg_conn = null;
pg_error = ex.Message;
}
if (pg_conn != null)
{
this.bw = new BackgroundWorker();
this.bw.WorkerReportsProgress = true;
this.bw.WorkerSupportsCancellation = true;
this.bw.DoWork += this.bwDoWork;
this.bw.ProgressChanged += onProgress;
this.bw.RunWorkerCompleted += onComplete;
}
}
示例2: BackgroundCall
private void BackgroundCall( string service, RunWorkerCompletedEventHandler callback, Func<string,NameValueCollection,HappyIndex> serviceCall, NameValueCollection parameters = null )
{
BackgroundWorker w = new BackgroundWorker();
w.RunWorkerCompleted += callback;
w.DoWork += WOnDoWork;
w.RunWorkerAsync(new BackgroundArgs{ Service = service, Parameters = parameters, ServiceCall = serviceCall });
}
示例3: GetBackgroundWorker
private BackgroundWorker GetBackgroundWorker(DoWorkQueuedEventHandler doWork, RunWorkerCompletedEventHandler workerCompleted)
{
BackgroundWorker bw = new BackgroundWorker();
bw.WorkerReportsProgress = false;
bw.WorkerSupportsCancellation = false;
bw.DoWork += (sender, args) =>
{
if (doWork != null)
{
args.Result=doWork(this, new DoWorkEventArgs(args.Argument));
}
};
bw.RunWorkerCompleted += (sender, args) =>
{
if (workerCompleted != null)
{
object result = args.Error == null ? args.Result : null;
workerCompleted(this,
new RunWorkerCompletedEventArgs(result, args.Error,
args.Cancelled));
}
Queue.Dequeue();
lock (_lock)
{
if (Queue.Count > 0)
{
((BackgroundWorker)this.Queue.Peek()).RunWorkerAsync();
}
}
};
return bw;
}
示例4: PageManager
/// <summary>
/// Creates and dispatches a PageManager to load a search page,
/// parse, extract, validate and return results using the
/// parameter callback EventHandlers
/// </summary>
/// <param name="pageNumber">Which search page number to load</param>
/// <param name="criteria">The user's search criteria</param>
/// <param name="pageLoadMethod">Supply the method to retrieve html</param>
/// <param name="updateProgressMethod">Callback for progress updates</param>
/// <param name="workerCompleteMethod">Callback when work complete</param>
public PageManager(int pageNumber,
SearchCriteria criteria,
Func<int, string, string> pageLoadMethod, // see explanation above
ProgressChangedEventHandler updateProgressMethod,
RunWorkerCompletedEventHandler workerCompleteMethod)
{
if (pageNumber < 1)
{
string msg = "Supplied page number ({0}) was < 0!";
msg = string.Format(msg,pageNumber);
throw new ArgumentOutOfRangeException(msg);
}
if (pageLoadMethod == null)
{
string msg = "Provided a null method to obtain page HTML!";
throw new InvalidOperationException(msg);
}
ProgressChanged += updateProgressMethod; // Callback
RunWorkerCompleted += workerCompleteMethod; // Callback
DoWork += Work;
_pageLoadMethod = pageLoadMethod;
_searchCriteria = criteria;
_pageNumber = pageNumber;
WorkerReportsProgress = true;
WorkerSupportsCancellation = true;
}
示例5: BackgroundConnectionHelper
public BackgroundConnectionHelper(DoWorkEventHandler AsyncDelegate, RunWorkerCompletedEventHandler GUIDelegate)
{
backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += AsyncDelegate;
backgroundWorker.RunWorkerCompleted += GUIDelegate;
backgroundWorker.WorkerSupportsCancellation = true;
}
示例6: Remove
public static void Remove(string path, RunWorkerCompletedEventHandler runworkerDone)
{
var bw = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = false };
bw.DoWork += RemoveFileFromIndex;
bw.RunWorkerCompleted += runworkerDone;
bw.RunWorkerAsync(path);
}
示例7: 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)
{
}
示例8: AsyncCommandBinding
public AsyncCommandBinding(ICommand command, ExecutedRoutedEventHandler executed, CanExecuteRoutedEventHandler canExecute, RunWorkerCompletedEventHandler runWokrerCompleted)
{
if (command == null)
{
throw new ArgumentNullException("command");
}
_task = new BackgroundWorker();
_task.DoWork += delegate
{
executed(null, null);
};
_task.RunWorkerCompleted += (s, e) =>
{
runWokrerCompleted(s, e);
_task.Dispose();
};
Command = command;
if (executed != null)
{
Executed += delegate
{
if (!_task.IsBusy)
_task.RunWorkerAsync();
};
}
if (canExecute != null)
{
CanExecute += canExecute;
}
}
示例9: 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;
}
示例10: FormInfo
public FormInfo(Form owner,
string Message,
DoWorkEventHandler DoWork,
RunWorkerCompletedEventHandler RunWorkerCompleted)
{
doInitialize(owner, Message, DoWork, RunWorkerCompleted, null);
}
示例11: Connect
//
public void Connect()
{
if (!_worker.IsBusy)
{
this._RunWorkerCompletedEventHandler = _imageGrabber.ConnectCompletedHandler;
_worker.RunWorkerAsync(_imageGrabber.ConnectHandler);
}
}
示例12: methodAsync
public static void methodAsync(int i, RunWorkerCompletedEventHandler onComplete)
{
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.RunWorkerCompleted += onComplete;
bw.RunWorkerAsync(i);
}
示例13: 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;
}
示例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: SetUp
private void SetUp(string statusText, RunWorkerCompletedEventHandler workerCompletedTask)
{
cdDialogPanel.Enabled = false;
cdConnectButton.Enabled = false;
cdTestButton.Enabled = false;
cdConnectStatusLabel.Text = statusText;
backgroundWorker.RunWorkerCompleted += workerCompletedTask;
backgroundWorker.RunWorkerAsync(ConnectionDetail);
}