Accessing static members across processes C#

2019-06-14 10:43发布

Ok, here is the problem. I have a third party c# lib and im kind of writing a tool about it. So there are a few static Containers that i want to monitor from another application but ofcourse i cant reach them in the domain of my app. A simple example would be :

namespace DefinedInAsembly1
{
     public class Resource
     {
       public static IList<DateTime> DateTimes {get;set;}
     }
}

 namespace DefinedInAssembly2
 {
    class RunningProgram
    {
      static void Main(string[] args)
      {
         while(true)
         {
          Resource.DateTimes.Add(DateTime.Now); 
          Thread.Sleep(10000);
         }
      }
    }
 }

namespace DefinedInAssembly3
{
 class ToolProgram
 {
    static void Main(string[] args)
    {
         //Accessing Resource.DateTimes with the values inserted from RunningProgram
         //Any ideas?
    }

 }
}

1条回答
beautiful°
2楼-- · 2019-06-14 10:57

You need to use any of available on host OS IPC (Inter Process Commnuication) tecniques:

So applications that have to be listened by someone, should expose themselves via one of these, so another application that would like to sniff, or affect the state of them, can communicate with them via these channels.

查看更多
登录 后发表回答