监控VS互斥在C# [英] Monitor vs Mutex in c#

查看:172
本文介绍了监控VS互斥在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/301160/what-are-the-differences-between-various-threading-synchronization-options-in-c\">What在C#中各种线程同步选项之间的区别是什么?

什么是监视器,并在C#中的互斥的区别?

What is the difference between a Monitor and a Mutex in C#?

在使用显示器时在C#中使用互斥锁?

When to use a Monitor and when to use a Mutex in C#?

推荐答案

A 显示器进行管理,并且更轻巧 - 但仅限于你的 AppDomain中。 A 互斥可以被命名,并且可以跨越进程(允许应用程序之间的一些简单的IPC场景),并可以在code想要观望手柄)被使用。

A Monitor is managed, and more lightweight - but is restricted to your AppDomain. A Mutex can be named, and can span processes (allowing some simple IPC scenarios between applications), and can be used in code that wants a wait-handle).

有关最简单的场景,显示器(通过锁定)的罚款。

For most simple scenarios, Monitor (via lock) is fine.

这篇关于监控VS互斥在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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