"尝试读取或写入受保护的内存"错误读取并行数据库的AutoCad [英] "Attempted to Read or write protected memory" error reading AutoCad databases in parallel

查看:698
本文介绍了"尝试读取或写入受保护的内存"错误读取并行数据库的AutoCad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到尝试读取或写入受保护的内存当我试图执行一些并行操作。我读的AutoCad数据库到内存做一些数据挖掘。我可以用普通的执行此循环,但不能用 Parallel.ForEach 。 ?任何想法

  Parallel.ForEach(_Files,(currentFile)=> 
{
变种_File = currentFile;
使用(数据库_Database =新的数据库(假,真))
{
_Database.ReadDwgFile(_File,FileOpenMode.OpenForReadAndAllShare,假,空);
_Database。 CloseInput(真);
//做的东西
}
});


解决方案

由于通过的Miiir 时,AutoCAD不支持多线程。



解决方法可能是与AutoCAD控制台(accoreconsole.exe)。如果你有一个外部的应用程序文件(.exe),用它来调用控制台,在那里你可以NETLOAD一个.NET插件,会做数据挖掘的几个实例。由于每个控制台实例都是一个独立的应用程序,也没有多线程。



我做了一些测试与AutoCAD控制台8核的机器上。正如你所看到的,整个过程需要(相比按顺序运行)的时间更少。选中该PDF我写道:使用.NET编程创建新的可能性的的AutoCAD®Core控制台




I am getting "Attempted to Read or write protected memory" when I try to perform some parallel operations. I am reading AutoCad Databases into to memory to do some data mining. I can do this with a regular for loop but not with a Parallel.ForEach. Any ideas?

Parallel.ForEach(_Files, (currentFile) =>
{
    var _File = currentFile;
    using (Database _Database = new Database(false, true))
    {
        _Database.ReadDwgFile(_File, FileOpenMode.OpenForReadAndAllShare, false, null);           
        _Database.CloseInput(true);
        // Do Stuff
    }
});

解决方案

As mentioned by Miiir, AutoCAD does not support multi-threading.

The workaround could be with AutoCAD Console (accoreconsole.exe). If you have an external app (.exe), use it to call several instances of the console, where you can NETLOAD a .NET plugin that will do your data mining. As each console instance is a separate app, there is no multi-thread.

I did some testing with AutoCAD Console on a 8-core machine. As you can see, the overall process takes less time (when compared to running in sequence). Check this PDF I wrote: Using .NET Programming to Create New Possibilities with the AutoCAD® Core Console

这篇关于"尝试读取或写入受保护的内存"错误读取并行数据库的AutoCad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆