[英]What is the best way to get multiple instances of a program to share information?
There's information my program has to send from one part to another, such as from DragEnter
to GiveFeedback
to change the cursor. 我的程序必须将某部分信息发送到另一部分,例如从
DragEnter
到GiveFeedback
才能更改光标。 This is easily done with a variable as a flag. 使用变量作为标志很容易做到这一点。 However – what if the user starts several instances of the program?
但是–如果用户启动该程序的多个实例怎么办?
One way would be to write information to a file, but it seems best to do as little disk operations as possible. 一种方法是将信息写入文件,但是似乎最好是进行尽可能少的磁盘操作。 Another way would be to use pipes, but it seems a bit complicated if there are many instances of the program.
另一种方法是使用管道,但是如果程序有很多实例,这似乎有点复杂。 Is there another way?
还有另一种方法吗?
Take a look at memory mapped files . 看一下内存映射文件 。
A memory-mapped file contains the contents of a file in virtual memory.
内存映射文件包含虚拟内存中文件的内容。 This mapping between a file and memory space enables an application, including multiple processes, to modify the file by reading and writing directly to the memory.
文件和内存空间之间的映射使应用程序(包括多个进程)可以通过直接读写内存来修改文件。
我将如何设置Model-View-Controller ……那是如果我正确理解了您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.