Merge pull request #3727 from ivandrofly/bc

simplify worker creation
This commit is contained in:
Nikolaj Olsson 2019-08-26 09:01:46 +02:00 committed by GitHub
commit ca44195f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -577,15 +577,11 @@ namespace Nikse.SubtitleEdit.Forms
_converted = 0;
_errors = 0;
_abort = false;
var worker1 = new BackgroundWorker();
var worker2 = new BackgroundWorker();
var worker3 = new BackgroundWorker();
worker1.DoWork += DoThreadWork;
worker1.RunWorkerCompleted += ThreadWorkerCompleted;
worker2.DoWork += DoThreadWork;
worker2.RunWorkerCompleted += ThreadWorkerCompleted;
worker3.DoWork += DoThreadWork;
worker3.RunWorkerCompleted += ThreadWorkerCompleted;
BackgroundWorker worker1 = SpawnWorker();
BackgroundWorker worker2 = SpawnWorker();
BackgroundWorker worker3 = SpawnWorker();
listViewInputFiles.BeginUpdate();
foreach (ListViewItem item in listViewInputFiles.Items)
{
@ -930,6 +926,14 @@ namespace Nikse.SubtitleEdit.Forms
SetControlState(true);
}
private BackgroundWorker SpawnWorker()
{
var worker = new BackgroundWorker();
worker.DoWork += DoThreadWork;
worker.RunWorkerCompleted += ThreadWorkerCompleted;
return worker;
}
/// <summary>
/// Text based functions retuires text, so no image to image convert
/// </summary>