与应用程序的多个实例的静态成员的行为 - C# [英] Static members behavior with multiple instance of application - C#

查看:133
本文介绍了与应用程序的多个实例的静态成员的行为 - C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作我的窗口应用程序,我使用一些静态成员我。

I'm working on my Window Application and i'm using some static members.

public class MyParameter
{
    public static string connectionString = "...";
}

现在,如果我安装我的电脑相同的应用程序的打开两个实例的应用程序。将的ConnectionString常见到的两个实例?或者每个实例都有它的connectionString?

Now if I install my application on computer and open two instance of same application. Will 'connectionString' common to the two instances?? Or every instance has its connectionString ?

推荐答案

变量静态与否的一部分,你的 aplication 的记忆。当你打开你的应用程序的两个实例的创建到的不同的的操作系统中的存储位置,所以在所有的两个变量之间没有任何关系。

The variable static or not is a part of your aplication memory. When you open 2 instances of your application you create to distinct memory locations in OS, so there is no any relation between those 2 variables at all.

如果你想创建一个(的关系),你要看看在不同的IPC(进程间通信)方法提供操作系统,如:

If you want to create one (relation), you have to look on different IPC (Inter Process Communication) methods available in OS, like:

  • Memory Mapped Files
  • Named Pipes
  • IPC Mechanisms in C# - Usage and Best Practices

这篇关于与应用程序的多个实例的静态成员的行为 - C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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