sharing variables between running applications in C#

前端 未结 4 926
眼角桃花
眼角桃花 2020-12-10 19:28

I am developing in C# two simple applications, running in the same local machine without network requirements.

The first application initializes an DLL (Class1) and

相关标签:
4条回答
  • 2020-12-10 19:36

    You can use .net Remoting to communicate between your two application.
    Remoting also does not require a network address to communicate.

    0 讨论(0)
  • 2020-12-10 19:46

    There is no simple way for Application B to read data created in Application A. Each application has its own address space and thus do not know of the others existence.

    But, there are ways to do this!

    See this question for one method..

    0 讨论(0)
  • 2020-12-10 19:52

    I've successfully used two methods:

    1. Use a database table to contain your common data. If you wrap your calls to it in transactions then you also protection from concurrency issues.

    2. Use PersistentDictionary to store your data, protected by a mutex. You must have some interprocess locking since PersistentDictionary can only be open by one process at a time.

    0 讨论(0)
  • 2020-12-10 19:57

    You need some sort of mechanism to communicate between the applications.

    This can be through the registry, files, memory mapped files etc...

    If both applications are expected to do write, you need to add synchronization logic to your code.

    0 讨论(0)
提交回复
热议问题