ADN reported they could not reproduce the error so threw this together for them to test
Also notice it with ADN example from
here Just pay attention while selecting different drawings in list box or when run a command.
I will be attaching some code that was thrown together quickly and sloppy just for a example to see if you experience the same issue, I am using a total different approach but this still shows the problem. So pay NO attention to efficiency, style or anything alike but is just for producing a issue. Also no error handling
Especially watch the "BIG A" at top left, but still notice it with ADN example but not so noticeable as doing one drawing.
Some notes about code:
The path to accoreconsole.exe is hard-coded to
"C:\Program Files\Autodesk\AutoCAD 2013\accoreconsole.exe" in CoreConsole class. So might need to change it
It will create a script file to your MyDocuments folder but delete it if no errors(could handle that in finally block).
It should create create a process for each core on your machine and when one finishes it will create another until all files have been done.
So for a quad core machine then no more than 4 accoreconsole.exe processes should run at one time and creating a new one when one of them finishes.
or for a duo core same as above but max of 2 accoreconsole.exe processes should run at one time.
If debug or run .exe in release folder you should click the button on WPF form and it should let you select folder.
Then for every drawing in the folder it will change all entities in ModelSpace to a random different color.
Depending on your machine here are some different size drawings to test with. They all have at least 24 drawings with 500 to 15,000 entities.
Below are some links with dwg's you can test with.
These folders contain drawings with just lines. circles, & arcs.
Contains 24 drawings with 500 entities each.
https://dl.dropbox.com/u/17374049/Test_500_24.zipContains 48 drawings with 500 entities each.
https://dl.dropbox.com/u/17374049/Test_500_48.zipContains 24 drawings with 5000 entities each.
https://dl.dropbox.com/u/17374049/Test_5000_24.zipContains 24 drawings with 15000 entities each.
https://dl.dropbox.com/u/17374049/Test_15000_24.zipAdded a webbrowser that defaults to the TheSwamp for no particular reason.
Should notice accoreconsole' running in taskmanager but all windows flicker when process id changes.
The button opens a FolderBrowserDialog box to select one folders downloaded from above.
Source code attached at bottom.
Again I am using a different approach than this example but this was just thrown together for ADN to see if they expirence the same problem, but basiclly uses the WaitAllOnebyOne appraoch with a limit on total number of processes at one time.
int cores = 0;
foreach (var item
in new System.Management.ManagementObjectSearcher("Select * from Win32_Processor").Get()) {
cores += int.Parse(item["NumberOfCores"].ToString());
}
int numofFiles = fis.Length;
int fileIndex = 0;
List
<Task
<CoreConsoleResult
>> tasks
= new List
<Task
<CoreConsoleResult
>>(); int totalTaskCreated = 0;
if (numofFiles > cores)
{
for (int i = 0; i < cores; i++)
{
CoreConsoleStartInfo ccsi
= new CoreConsoleStartInfo
(fis
[fileIndex
].FullName, scriptPath
); Task<CoreConsoleResult> t = RunAcCoreConsole(ccsi);
tasks.Add(t);
fileIndex++;
totalTaskCreated++;
}
}
else
{
for (int i = 0; i < numofFiles; i++)
{
CoreConsoleStartInfo ccsi
= new CoreConsoleStartInfo
(fis
[fileIndex
].FullName, scriptPath
); Task<CoreConsoleResult> t = RunAcCoreConsole(ccsi);
tasks.Add(t);
fileIndex++;
totalTaskCreated++;
}
}
int done = 0;
while (done < numofFiles)
{
int index = Task.WaitAny(tasks.ToArray());
done++;
tasks.RemoveAt(index);
if (totalTaskCreated < numofFiles)
{
CoreConsoleStartInfo ccsi
= new CoreConsoleStartInfo
(fis
[fileIndex
].FullName, scriptPath
); Task<CoreConsoleResult> t = RunAcCoreConsole(ccsi);
tasks.Add(t);
totalTaskCreated++;
if (fileIndex < numofFiles - 1)
fileIndex++;
}
}
sb.DeleteScriptFile();
}
static Task<CoreConsoleResult> RunAcCoreConsole(CoreConsoleStartInfo ccsi)
{
Task<CoreConsoleResult> task = Task.Factory.StartNew<CoreConsoleResult>(() =>
{
CoreConsoleResult ccr;
using (Process process
= new Process
()) {
ProcessStartInfo startInfo
= new ProcessStartInfo
(); startInfo.FileName = acCoreConsolePath;
string ApplicationArguments = string.Format("/i \"{0}\" /s \"{1}\" /isolate CoreConsole", ccsi.FileName, ccsi.ScriptFilePath);
startInfo.Arguments = ApplicationArguments;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
process.StartInfo = startInfo;
process.Start();
ccr
= new CoreConsoleResult
(ccsi
.FileName, process
.StandardOutput.ReadToEnd()); process.WaitForExit();
}
return ccr;
});
return task;
}
Will post approach I am taking when I get time to do more testing and refactor.
Windows 7 64 bit.