Inter-process communication

前端 未结 9 1372
傲寒
傲寒 2020-12-01 08:42

I have two applications: X and Y.
X is the main application and it handles a lot of XML files. It has a history of more than 10 years and half a dozen techniques have

相关标签:
9条回答
  • You can do it more simply, since you're just trying to find out if one app is running from another one. As long as they're running on the same machine by the same user, you can have X simply use FindWindow() to see if Y is currently running. Just make sure you give Y a meaningful name (in the sample below, it's TXMLFormatterForm):

    var
      XMLWindow: HWnd;
    begin
      XMLWindow := FindWindow('TXMLFormatterForm', nil);
      if XMLWindow > 0 then
        // Y is running
    end;
    

    You can also use Y's window caption (title), as long as you're sure it's distinct:

    XMLWindow := FindWindow(nil, 'Workshop Alex's XML Formatter');
    
    0 讨论(0)
  • 2020-12-01 09:12

    Here are some real data about speed, according to diverse client/server investigation.

    All benchmarks were run locally on one computer. You can achieve more than 15000 queries per second on direct access, 4300 queries per second on HTTP/1.1 remote access. This was benchmarked on a Notebook using a Centrino2 CPU, with AntiVirus ON.

    2.5. Client server access: 
      - Http client keep alive: 3001 assertions passed
         first in 7.87ms, done in 153.37ms i.e. 6520/s, average 153us
      - Http client multi connect: 3001 assertions passed
         first in 151us, done in 305.98ms i.e. 3268/s, average 305us
      - Named pipe access: 3003 assertions passed
         first in 78.67ms, done in 187.15ms i.e. 5343/s, average 187us
      - Local window messages: 3002 assertions passed
         first in 148us, done in 112.90ms i.e. 8857/s, average 112us
      - Direct in process access: 3001 assertions passed
         first in 44us, done in 41.69ms i.e. 23981/s, average 41us
      Total failed: 0 / 15014  - Client server access PASSED
    

    This benchmark tests both client and server speed, and is not multithreaded (even if our framework is multi-thread safe).

    So you can guess that, for a 4 KB data block of JSON content for each request:

    1. The direct access (like your dll approach) is the fastest, and less resource consuming.
    2. Then GDI messages.
    3. Then named pipes.
    4. Then FastCGI and HTTP (depending on your web server for FastCGI, the HTTP classes are very low consuming).

    Keep alive connections are HTTP/1.1 connections, and multi connect is plain HTTP/1.0, with a new connection for every request. Multi-connect is not so bad, because from the server point of view, we used an efficient Thread Pool based on I/O completion ports.

    See http://synopse.info/forum/viewtopic.php?id=90

    0 讨论(0)
  • 2020-12-01 09:18

    I would go the memory mapped files direction, but I would not implement directly in the code path..instead I would go through an intermediate object that would perform the writing to the memory mapped file, this way it could be replaced with one that just discarded the data if it was not in place.

    When the program first starts (or is told to check via a configuration change) the system would either create the stub "do nothing" or the "log via memory mapped files" object. This also gives you the capability of adding a later debugger when the need arises...such as a UDP logger for network logging, etc.

    You can use the "FindWindow" call to see if your debugger is running.

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