Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

We have two applications running on single machine,one of which is web application that responses every request by reading xml document(s).We wish to add the case that when the new xml file is created or existing file has replaced,application must not read file until its all changed and by the time the case happens,it must respond with old file.

Since web applications works for request/respond cycle,we decided that this cycle shouldn't be interfered knowing that time between file changing and request time is obscured in live-running system,we must split file reading process.For that purpose,we use FileSystemWatcher in local machine with windows or console application(or some other says use WCF instead).

Now that we come to question in above case,saying how can we communicate these two (or more) applications?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
283 views
Welcome To Ask or Share your Answers For Others

1 Answer

Look like you'd be interested in Named Pipes to enable IPC, check out this link for an example, or this MSDN link.

Grabbing the code from the NamedPipeServerStream page of MSDN illustrates most simply (see the NamedPipeClientStream page for the client side):

using (NamedPipeServerStream pipeServer =
    new NamedPipeServerStream("testpipe", PipeDirection.Out))
{
    Console.WriteLine("NamedPipeServerStream object created.");

    // Wait for a client to connect
    Console.Write("Waiting for client connection...");
    pipeServer.WaitForConnection();

    Console.WriteLine("Client connected.");
    try
    {
        // Read user input and send that to the client process.
        using (StreamWriter sw = new StreamWriter(pipeServer))
        {
            sw.AutoFlush = true;
            Console.Write("Enter text: ");
            sw.WriteLine(Console.ReadLine());
        }
    }
    // Catch the IOException that is raised if the pipe is broken
    // or disconnected.
    catch (IOException e)
    {
        Console.WriteLine("ERROR: {0}", e.Message);
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...