求购:不从AbandonedMutexException遭受跨进程同步 [英] Wanted: Cross-process synch that doesn't suffer from AbandonedMutexException

查看:289
本文介绍了求购:不从AbandonedMutexException遭受跨进程同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有获得互斥体,然后终止多个线程。

I have several threads that acquire Mutexes and then terminate.

的互斥被存储在主资源库,而当该程序存在被正确释放。然而,当分配一个互斥体的线程存在,互斥锁被自动释放,以及随后的获取AbandonedMutexException(也可根据的文档)。

The mutexes are stored in a main repository, and are properly released when the program exists. However, when the thread that allocated a Mutex exists, the mutex gets released automatically, and subsequent acquire AbandonedMutexException (also according to the documentation).

我怎样才能避免这种情况的异常,并继续使用分配线程完成,即使一个互斥?难道还有其他的,更合适的同步结构在.net不具有此限制。

How can I avoid this exception, and keep using a Mutex even after the allocating thread finished? Is there another, more appropriate synchronization construct in .Net that doesn't have this limitation.

注意 - 我在寻找类似的语义互斥一个跨进程同步机制

Note - I am looking for a cross-process synch mechanism with similar semantics to Mutex.

推荐答案

看起来的EventWaitHandle我想要做什么。它有一个构造函数的名称,所以它的完美的跨进程同步,它不存在这个问题。

Looks like EventWaitHandle does what I want. It has a constructor that takes a name, so it's perfect for cross-process synch, and it doesn't have this problem.

这篇关于求购:不从AbandonedMutexException遭受跨进程同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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