Parallelism in Studio 2015

Hi everyone,

For a plugin enhancing the concordance search, I used to implement a Parallel.Foreach to loop through the translation providers defined in a project and run a concordance search on each of them. This worked well in Studio 2014 in combination with Groupshare 2014.

I am currently in the process of upgrading this plugin for Studio 2015 (in combination with GS2015) and I have noticed that the above-mentioned Parallel.ForEach loop never ends and prevent the further execution of the code. The content of the loop runs normally but the code coming after the loop is never executed.

Currently, I turned my Parallel.Foreach loop back to a normal foreach and it works. However, I would like to use parallelism here for obvious performance purposes.

Does anyone know whether something has changed in Studio 2015 concerning multi-threading or parallel tasks?

Thanks in advance for any hint or advice.

Regrads,

Laurent

Parents
  • Studio is not necessarily thread safe so you might have surprises like this. Can you please post a sample code with your Parallel.Foreach? I want to see exactly what objects are used in your loop.

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • Hi Romulus,

    Please find hereby the Parallel.Foreach:
     
    Parallel.ForEach(currentProj.GetTranslationProviderConfiguration().Entries, (aTM) =>
    {
    int tmPos = TMOrdering.FirstOrDefault(x => x.Value == aTM.MainTranslationProvider.Uri.AbsoluteUri).Key;

    if ("http://" + aTM.MainTranslationProvider.Uri.Authority == Properties.Settings.Default.tmSrvAddress && aTM.PerformConcordanceSearch == true)
    {
    ServerBasedTranslationMemory selectedTM = tmSRV.GetTranslationMemory(Globals.getServerTMPath(aTM.MainTranslationProvider.Uri.Query), TranslationMemoryProperties.All);

    if (selectedTM.SupportsLanguageDirection(lgPair))
    {
    ServerBasedTranslationMemoryLanguageDirection srvTMLgDir = selectedTM.GetLanguageDirection(lgPair);
    SearchResults tmLookupResults = srvTMLgDir.SearchText(concSettings, searchStr);

    #region Project TM
    //Check if the translation provider has a project TM. launch a search on it if yes.
    if (aTM.ProjectTranslationMemories.Count > 0)
    {
    FileBasedTranslationMemory projTM = new FileBasedTranslationMemory(aTM.ProjectTranslationMemories.FirstOrDefault().Uri);
    SearchResults projTMResults = projTM.LanguageDirection.SearchText(concSettings, searchStr);
    Tuple<int, string, SearchResults> projTMResultsSet = new Tuple<int, string, SearchResults>(0, "Project TM", projTMResults);
    concSearchResults.Add(projTMResultsSet);
    }
    #endregion

    Tuple<int, string, SearchResults> tmResults = new Tuple<int, string, SearchResults>(tmPos, selectedTM.Name, tmLookupResults);
    concSearchResults.Add(tmResults);
    }
    }
    });
    return concSearchResults;
    }

    Regards,

    Laurent

Reply
  • Hi Romulus,

    Please find hereby the Parallel.Foreach:
     
    Parallel.ForEach(currentProj.GetTranslationProviderConfiguration().Entries, (aTM) =>
    {
    int tmPos = TMOrdering.FirstOrDefault(x => x.Value == aTM.MainTranslationProvider.Uri.AbsoluteUri).Key;

    if ("http://" + aTM.MainTranslationProvider.Uri.Authority == Properties.Settings.Default.tmSrvAddress && aTM.PerformConcordanceSearch == true)
    {
    ServerBasedTranslationMemory selectedTM = tmSRV.GetTranslationMemory(Globals.getServerTMPath(aTM.MainTranslationProvider.Uri.Query), TranslationMemoryProperties.All);

    if (selectedTM.SupportsLanguageDirection(lgPair))
    {
    ServerBasedTranslationMemoryLanguageDirection srvTMLgDir = selectedTM.GetLanguageDirection(lgPair);
    SearchResults tmLookupResults = srvTMLgDir.SearchText(concSettings, searchStr);

    #region Project TM
    //Check if the translation provider has a project TM. launch a search on it if yes.
    if (aTM.ProjectTranslationMemories.Count > 0)
    {
    FileBasedTranslationMemory projTM = new FileBasedTranslationMemory(aTM.ProjectTranslationMemories.FirstOrDefault().Uri);
    SearchResults projTMResults = projTM.LanguageDirection.SearchText(concSettings, searchStr);
    Tuple<int, string, SearchResults> projTMResultsSet = new Tuple<int, string, SearchResults>(0, "Project TM", projTMResults);
    concSearchResults.Add(projTMResultsSet);
    }
    #endregion

    Tuple<int, string, SearchResults> tmResults = new Tuple<int, string, SearchResults>(tmPos, selectedTM.Name, tmLookupResults);
    concSearchResults.Add(tmResults);
    }
    }
    });
    return concSearchResults;
    }

    Regards,

    Laurent

Children
No Data