Mac上的单一实例应用程序的理想方式 [英] Ideal way to single-instance apps on the Mac

查看:117
本文介绍了Mac上的单一实例应用程序的理想方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows上,通常的做法是创建一个命名的互斥体,并使用其存在来确定给定应用程序的实例已在运行。

On Windows, it's common practice to create a named mutex and use the presence of that to determine that an instance of a given app is already running. This has its drawbacks, but mostly works.

我可以想办法在Mac上执行此操作:

I can think of a ways to do this on the Mac:


  1. 命名为pthread mutexes

  2. 枚举运行的进程并查找与
  3. 匹配的进程
  4. 创建并锁定文件

  1. named pthread mutexes
  2. enumerate running processes and look for one that matches
  3. create and lock a file

Cocoa / Carbon内置的东西比上面的选项容易吗?如果没有,在mac上使用最多的三个?我会假设2或3 ...

Is there something built into Cocoa/Carbon that's easier than the options above? If not, which of the three are most used on the mac? I would assume 2 or 3...

推荐答案

Macs没有像Windows一样的实例。一般来说,你希望应用程序运行两次,你实际上需要复制二进制文件,然后双击复制的版本。

Macs do not have instances in the same way as Windows does. Generally speaking you want the application running twice you physically need to copy the binary and then double click on the copied version as well.

如果你需要两个应用程序运行那么你不像Mac用户那样:)

If you need two instances of an application running then you are not thinking like a Mac user :).

编辑:这在技术上是 不是真的。检查意见。

This is technically not true. Check the comments.

这篇关于Mac上的单一实例应用程序的理想方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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