Results 1 to 5 of 5

Thread: [RESOLVED] IPC remoting -- Share an object between two processes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Resolved [RESOLVED] IPC remoting -- Share an object between two processes

    I'm following this article to do the remoting
    http://www.codeguru.com/csharp/cshar...cle.php/c9251/

    But the problem is that the server and the client are not really sharing the object (two copies are generated).

    I'm using singleton mode.
    Code:
     IpcChannel channel = new IpcChannel("EDMChannel");
                ChannelServices.RegisterChannel(channel);
                RemotingConfiguration.RegisterWellKnownServiceType (typeof(Pipe), "Pipeline", WellKnownObjectMode.Singleton);

    The following is my remote-able class

    Code:
    namespace Remoting
    {
        public class Pipe : MarshalByRefObject
        {
            private static Record[] records = new Record[300];
            private static int current_pointer;        
            private static int window_size=300;
               
            public static void Push(string message)
            {
                records[current_pointer] = new Record(DateTime.Now, message);
                current_pointer++;
                if (current_pointer >= window_size)
                {
                    current_pointer = 0;
                }
            }
            public static List<Record> Pop(int ask)
            {
                List<Record> result = new List<Record>();
                if (ask < 0 || ask > window_size)
                {
                    return null;
                }
    
                if (ask < current_pointer)
                {
                    for (int i=ask; i<current_pointer; i++)
                    {
                        result.Add(records[i]);
                    }
                }
                else
                {
                    for (int i = ask; i < window_size; i++)
                    {
                        result.Add(records[i]);
                    }
                    for (int i = 0; i < current_pointer; i++)
                    {
                        result.Add(records[i]);
                    }
                }
                
                return result;
            }
        }  
    }
    I want to share "Pipe" object across the server and the client with all the data intact. When one side updates the object, it must be visible on the other side.

    How do I go about that?



    Ps: I've tried making the class nonstatic and singleton but to no avail
    Last edited by winterslam; Nov 4th, 2009 at 01:05 AM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: IPC remoting -- Share an object between two processes

    Found this, I hope it helps.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Re: IPC remoting -- Share an object between two processes

    Quote Originally Posted by dee-u View Post
    Found this, I hope it helps.
    The code doesn't look that straightforward. It has a lot of unmanaged DLL calls

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Re: IPC remoting -- Share an object between two processes

    Resolved


    I use
    Code:
    RemotingServices.Marshal(pipeline, "EDMMessagePipeline.rem");
    instead of

    Code:
    RemotingConfiguration.RegisterWellKnownServiceType (typeof(Pipe), "EDMMessagePipeline.rem", WellKnownObjectMode.Singleton);

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [RESOLVED] IPC remoting -- Share an object between two processes

    Cool. =)
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width