首页 \ 问答 \ DLL和线程的问题(Problems with DLL & threads)

DLL和线程的问题(Problems with DLL & threads)

请帮我解决以下问题:

  • 我实现了一个线程做一些工作。 该线程隐式调用一些外部DLL。 当然,我尽力处理这些DLL中的可能错误(使用try ... catch)但无法处理意外错误(例如内存异常)。

  • 如果其中一个DLL遇到问题(bug或循环某处)并最终卡住,则该线程将永远不会完成(或关闭)。

在我的程序中,每个线程都与一个会话相关联(会话数量有限)。 假设所有线程都被卡住,传入的会话将不得不永远等待。

有没有办法强制线程停止,即使它仍在工作或卡住?

请注意,我正在使用Boost库进行C ++编程。

欢迎任何建议!

提前致谢!


Please help me the following problems:

  • I implement a thread doing some jobs. This thread implicitly calls some external DLLs. Of course, I tried my best to handle possible errors in those DLLs (using try ... catch) but cannot handle unexpected errors (e.g. memory exception).

  • If one of DLLs encounters problem(s) (bug or loop somewhere) and eventually gets stuck, this thread will never be completed (or close).

In my program, each thread is associated with a session (number of sessions is limited). Assume all threads get stuck, incoming session will have to wait forever.

Is there any way to force a thread to stop even if it is still working or gets stuck?

Note that I am using C++ programming with Boost library.

Any advises are welcome!

Thanks in advance!


原文:https://stackoverflow.com/questions/21129916
更新时间:2023-01-26 08:01

最满意答案

这对我来说是一个艰难的问题,但你可能会考虑下面的结构:

Entity
---------
EntityId
ProfileId --nullable
UserId --nullable

RightsSet
----------
EntityId
CanView
CanEdit
ObjectTypeID
ObjectID

使用此方法,您可以在Entity表中的ProfileIdUserId上指定UNIQUE约束,然后根据需要在RightsSet创建RightsSet记录。 当Entity中的ProfileIdUserId都为null或者它们都具有值时,可能存在两个问题。 您可以在插入记录之前进行一些验证,以确保不会发生这种情况。


This was a tough one for me to wrap my head around but you might consider the structure below:

Entity
---------
EntityId
ProfileId --nullable
UserId --nullable

RightsSet
----------
EntityId
CanView
CanEdit
ObjectTypeID
ObjectID

With this method you can specify a UNIQUE constraint on ProfileId and UserId in the Entity table and then create as many records in RightsSet as is needed. Two possible problems would be when ProfileId and UserId in Entity are both null or when they both have values. You could probably do some validation before you insert records to ensure this does not happen.

相关问答

更多
  • 多对多的关系往往会发展藤壶 - 与关系本身相关的额外数据,而不是关系中的任何一方(根据我的经验,这是常态而非例外)。 例如,成员和组可能以多对多的方式关联,并且您想知道某个成员加入某个组的时间,他们的成员状态(新建,挂起,暂停,等等)等等。 如果您从多对多直接建模关系开始,并相应地编写所有代码,则第一个加入连接表的额外列将会破坏您的模型和一堆代码。 Many-to-many relationships quite often develop barnacles — extra data that is as ...
  • 您必须使用InverseProperty ,如下所示。 [InverseProperty("allClassB")] public virtual ClassB currentClassB { get; set; } public int? currentClassBID { get; set; } DataAnnotations - InverseProperty属性: You have to use InverseProperty as shown below. [InverseProperty("a ...
  • 一对多 :一个人有很多技能,一个技能不会重复使用在人之间, 单向 :一个人可以通过它的Set直接引用技能 双向 :每个“孩子”技能有一个单一的指针回到人(在您的代码中未显示) 多对多 :一个人有很多技能,一个技能在人 单向 :一个人可以通过它的Set直接引用技能 双向 :技能有一组与之相关的人员。 在一对多关系中,一个对象是“父”,一个是“小孩”。 父母控制孩子的存在。 在“多对多”中,任何一种类型的存在都取决于它们之间的东西(在较大的应用程序上下文中)。 您的主题(域)应该决定关系是一对多还是多对多 - ...
  • 一对一:使用外键引用表: student: student_id, first_name, last_name, address_id address: address_id, address, city, zipcode, student_id # you can have a # "link back" if you need 一对多 :使用外键链接到“一”方面的关系: teachers: ...
  • 您的JPA提供程序会创建其他表( author_email和author_phone ),因为您有双向关系,但未指出这些关系的哪一方是所有者( mappedBy属性)。 对Author类中的集合进行以下更改,它应该按预期工作。 @OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER, mappedBy = "author") private Set phones; @OneToMany(cascade = Casca ...
  • 这对我来说是一个艰难的问题,但你可能会考虑下面的结构: Entity --------- EntityId ProfileId --nullable UserId --nullable RightsSet ---------- EntityId CanView CanEdit ObjectTypeID ObjectID 使用此方法,您可以在Entity表中的ProfileId和UserId上指定UNIQUE约束,然后根据需要在RightsSet创建RightsSet记录。 当Entity中的Profil ...
  • SQL 2005: WITH X AS ( SELECT id, min(value) as minval from Foo group by id ) SELECT * FROM ( SELECT Foo.*, RANK() OVER ( PARTITION by Foo.id order by Foo.hid, Foo.value ) as Rank FROM Foo JOIN X on Foo.id = X.id and Foo.value = X.minval ) tmp WHER ...
  • 使用NPoco 3,您只能映射1个一对多或多对多关系。 示例必须存在的项目是Product类中的[NPoco.PrimaryKey(“ProductId”)]标记。 所以你这样做: string sql = "sql with product-categorie relation"; List products = db.Fetch(x => x.Categories, sql); 要么 string sql = "sql with product-productVar ...
  • 你会加入。 如果您想在结果中使用A,那么: select a.*, b.*, c.*, d.* from a join b on b.id_a = a.id_a left join bc on bc.id_b = b.id_b -- bridge table b <-> c left join c on c.id_c = bc.id_c left join bd on bd.id_b = b.id_b -- bridge table b <-> d left join d on d.id_d = bd.id ...
  • jOOQ还没有开箱即用的这种POJO映射,但是你可以利用像ModelMapper这样的东西,它具有专门的jOOQ集成 ,可以在一定程度上适用于这些场景。 从本质上讲,ModelMapper挂钩到jOOQ的RecordMapper API。 更多细节在这里: http://www.jooq.org/doc/latest/manual/sql-execution/fetching/recordmapper/ http://www.jooq.org/doc/latest/manual/sql-execution/ ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。