GetLabel via Parallel.ForEach Loop Error
Posted: Thu May 26, 2016 8:42 pm
I have a process that does GetLabel to 5 different servers. To speed up the process, I used Async/Await for each of the server calls. I was told it would be better to use Parallel.ForEach. The problem is that I get the following error(see below). Is there a way to fix this problem? I use the code below the error to run the GetLabel.
vault>
<error>
<exception>System.IO.IOException: The process cannot access the file '\\ghprodetl4\src_trs\script\test.test' because it is being used by another process.
at VaultClientIntegrationLib.GetOperations.performLabelGet(String objectPath, String label, String labelSubItem, String labelWorkingFolder, String destPath, GetOptions go)
at VaultClientIntegrationLib.GetOperations.ProcessCommandGetLabelToLocationOutsideWorkingFolder(String objectPath, String label, String labelSubItem, GetOptions getOptions, String destPath)
at VaultCmdLineClient.VaultCmdLineClient.ProcessCommand(Args curArg)
at VaultCmdLineClient.VaultCmdLineClient.Main(String[] args)</exception>
</error>
var psi = new ProcessStartInfo
{
FileName = vaultRequest.PropertiesFile.Plink,
Arguments = string.Format("-P 44022 {0}@ghelsiapp \"GETLABEL -repository \"{3}\" \"{4}\" \"{5}\" -backup no -setfiletime modification -{1} \"{2}\" -verbose \""
, vaultRequest.Username, workingFolder, writeLocation, vaultRequest.Repository, ObjectPath, vaultRequest.ActualLabelName),
RedirectStandardError = true,
RedirectStandardOutput = true,
RedirectStandardInput = true,
UseShellExecute = false,
CreateNoWindow = true
};
var getLatestTask = new Task(() => ProcessDos(psi, vaultRequest));
getLatestTask.Start();
getLatestTask.Wait();
vault>
<error>
<exception>System.IO.IOException: The process cannot access the file '\\ghprodetl4\src_trs\script\test.test' because it is being used by another process.
at VaultClientIntegrationLib.GetOperations.performLabelGet(String objectPath, String label, String labelSubItem, String labelWorkingFolder, String destPath, GetOptions go)
at VaultClientIntegrationLib.GetOperations.ProcessCommandGetLabelToLocationOutsideWorkingFolder(String objectPath, String label, String labelSubItem, GetOptions getOptions, String destPath)
at VaultCmdLineClient.VaultCmdLineClient.ProcessCommand(Args curArg)
at VaultCmdLineClient.VaultCmdLineClient.Main(String[] args)</exception>
</error>
var psi = new ProcessStartInfo
{
FileName = vaultRequest.PropertiesFile.Plink,
Arguments = string.Format("-P 44022 {0}@ghelsiapp \"GETLABEL -repository \"{3}\" \"{4}\" \"{5}\" -backup no -setfiletime modification -{1} \"{2}\" -verbose \""
, vaultRequest.Username, workingFolder, writeLocation, vaultRequest.Repository, ObjectPath, vaultRequest.ActualLabelName),
RedirectStandardError = true,
RedirectStandardOutput = true,
RedirectStandardInput = true,
UseShellExecute = false,
CreateNoWindow = true
};
var getLatestTask = new Task(() => ProcessDos(psi, vaultRequest));
getLatestTask.Start();
getLatestTask.Wait();