private static void HandleDownloadSubtitle(Video video) { var subtitleProcess = new BackgroundProcessor<Action>(2, action => action(), "Subtitle provider"); var subtitleController = new SubtitleProviderProcessor(Logger.LoggerInstance, SubtitleProviderProcessor.ProvideRequestSourceEnum.Ui); subtitleProcess.Inject(() => subtitleController.ProvideSubtitleForVideo(video)); }
private static void HandleDownloadSubtitle(Video video) { var subtitleProcess = new BackgroundProcessor <Action>(2, action => action(), "Subtitle provider"); var subtitleController = new SubtitleProviderProcessor(Logger.LoggerInstance, SubtitleProviderProcessor.ProvideRequestSourceEnum.Ui); subtitleProcess.Inject(() => subtitleController.ProvideSubtitleForVideo(video)); }
public void Stop() { _userPref.Save(); if (_processor != null) { _processor.Stop(); _processor = null; } }
private void m_btnProcess_Click(object sender, EventArgs e) { m_btnOk.Enabled = m_btnSkipAll.Enabled = false; lock (this) { if (m_outputForm == null || m_outputForm.IsDisposed) { m_outputForm = new OutputForm(); m_outputForm.Show(this); } else { m_outputForm.Clear(); } } RefTextDevUtilities.ReferenceTextUtility.DifferencesToIgnore = RefTextDevUtilities.ReferenceTextUtility.Ignore.Nothing; if (m_chkPunctuation.Checked) { RefTextDevUtilities.ReferenceTextUtility.DifferencesToIgnore = RefTextDevUtilities.ReferenceTextUtility.Ignore.Punctuation; } else if (m_chkQuoteMarkDifferences.Checked) { RefTextDevUtilities.ReferenceTextUtility.DifferencesToIgnore = RefTextDevUtilities.ReferenceTextUtility.Ignore.QuotationMarkDifferences; } else if (m_chkCurlyVsStraight.Checked) { RefTextDevUtilities.ReferenceTextUtility.DifferencesToIgnore = RefTextDevUtilities.ReferenceTextUtility.Ignore.CurlyVsStraightQuoteDifferences; } if (m_chkWhitespace.Checked) { RefTextDevUtilities.ReferenceTextUtility.DifferencesToIgnore |= RefTextDevUtilities.ReferenceTextUtility.Ignore.WhitespaceDifferences; } if (m_chkSymbols.Checked) { RefTextDevUtilities.ReferenceTextUtility.DifferencesToIgnore |= RefTextDevUtilities.ReferenceTextUtility.Ignore.Symbols; } if (m_chkAttemptToRegularizeQuotationMarksToMatchEnglish.Enabled) { RefTextDevUtilities.ReferenceTextUtility.AttemptToAddQuotationMarksToMatchEnglish = m_chkAttemptToRegularizeQuotationMarksToMatchEnglish.Checked; } m_passes.Clear(); m_passes.Push(RefTextDevUtilities.ReferenceTextUtility.Mode.Generate); m_passes.Push(RefTextDevUtilities.ReferenceTextUtility.Mode.FindDifferencesBetweenCurrentVersionAndNewText); BackgroundProcessor.RunWorkerAsync(); }
private void OnBackgroundProcessorWorkCompleted(object s, RunWorkerCompletedEventArgs args) { if (m_passes.Count == 0) { foreach (var newRefTextRow in m_dataGridRefTexts.Rows.OfType <DataGridViewRow>().Where(r => s_createActions.Contains((string)r.Cells[colAction.Index].Value) && !r.Cells[colHeSaidText.Index].ReadOnly && !r.Cells[colIsoCode.Index].ReadOnly)) { // Generate a new metadata file with the above info var languageName = (string)newRefTextRow.Cells[colName.Index].Value; var folder = Data.GetLanguageInfo(languageName).OutputFolder; var projectPath = Path.Combine(folder, languageName + Constants.kProjectFileExtension); if (File.Exists(projectPath)) { HandleMessageRaised($"File {projectPath} already exists! Skipping. Please verify contents.", true); } else { var metadata = XmlSerializationHelper.DeserializeFromString <GlyssenDblTextMetadata>(Resources.refTextMetadata); metadata.Language = new GlyssenDblMetadataLanguage { Name = languageName, HeSaidText = newRefTextRow.Cells[colHeSaidText.Index].Value as string, Iso = newRefTextRow.Cells[colIsoCode.Index].Value as string }; metadata.AvailableBooks = new List <Book>(); ProjectUtilities.ForEachBookFileInProject(folder, (bookId, fileName) => metadata.AvailableBooks.Add(new Book { Code = bookId, IncludeInScript = true })); metadata.LastModified = DateTime.Now; Exception error; XmlSerializationHelper.SerializeToFile(projectPath, metadata, out error); if (error != null) { HandleMessageRaised(error.Message, true); } } } m_btnOk.Enabled = m_btnSkipAll.Enabled = true; } else { BackgroundProcessor.RunWorkerAsync(); } }
private void m_btnProcess_Click(object sender, EventArgs e) { m_btnOk.Enabled = false; lock (this) { if (m_outputForm == null || m_outputForm.IsDisposed) { m_outputForm = new OutputForm(); m_outputForm.Show(this); } else { m_outputForm.Clear(); } } m_passes.Clear(); m_passes.Push(RefTextDevUtilities.ReferenceTextUtility.Mode.Generate); m_passes.Push(RefTextDevUtilities.ReferenceTextUtility.Mode.FindDifferencesBetweenCurrentVersionAndNewText); BackgroundProcessor.RunWorkerAsync(); }
// Use this for initialization void Start() { Debug.Log(string.Format("{0} start:", System.DateTime.Now)); Debug.Log(string.Format("ForegroudTimer start:", System.DateTime.Now)); ForegroudTimer timer = new ForegroudTimer(o => { Debug.Log(string.Format("{0} ForegroudTimer trigger:", System.DateTime.Now)); }, null, 1000, 2000); ForegroundInvoker.Invoke(() => { Debug.Log(string.Format("ForegroundInvoker invoke:", System.DateTime.Now)); }); BackgroundProcessor.AppendAction(() => { timer.Dispose(); Debug.Log(string.Format("{0} ForegroudTimer end:", System.DateTime.Now)); }, 4000, 1, 8000); }