在同一个AppPool中跨应用程序共享变量? [英] Shared variable across applications within the same AppPool?

查看:69
本文介绍了在同一个AppPool中跨应用程序共享变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Asp.net FW 4.6.

I'm using Asp.net FW 4.6.

我在同一应用程序池下有两个应用程序,它们需要(恒定地)读取预定义的值,该值是要更改的对象.

I have two applications under the same application pool that need to read (constantly) a predefined value which is object to change.

不能使用静态变量,因为不会共享不同的应用程序(即使在同一应用程序池下).

Static variables can't be used because different apps (even under same app pool) - won't be shared.

DB/文件/服务器是已知选项.

DB/File/Server are known options.

但是:

问题:

我是否可以编写任何可以存储在mem值中的代码,这些代码可以通过同一应用程序池下的多个应用程序进行访问?

Is there any code that I can write that can store in mem value which will be accessible through multiple applications which are under the same App Pool ?

类似的东西:

MyAppPool  

    App1   -> func("royi") = 1
    App2   -> var a= func2("royi"); //1

推荐答案

所有进程间通信方式,例如内存映射文件在两个应用程序之间共享内存.

All ways of interprocess communication, such as Memory Mapped Files and Named Pipes can also be used for sharing data across applications within single AppPool, see for example Sharing memory between two applications.

由于同一AppPool中的所有应用程序都驻留在同一进程中,并且仅由AppDomain边界分隔,因此您还有其他一些选择:

Because all apps in the same AppPool resides in the same process and are separated just by AppDomain boundaries, you have some additional options:

这篇关于在同一个AppPool中跨应用程序共享变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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