|
-
Nov 3rd, 2009, 03:00 AM
#1
Thread Starter
Addicted Member
[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.
-
Nov 3rd, 2009, 03:22 AM
#2
Re: IPC remoting -- Share an object between two processes
Found this, I hope it helps.
-
Nov 3rd, 2009, 04:15 AM
#3
Thread Starter
Addicted Member
Re: IPC remoting -- Share an object between two processes
 Originally Posted by dee-u
Found this, I hope it helps.
The code doesn't look that straightforward. It has a lot of unmanaged DLL calls
-
Nov 4th, 2009, 01:04 AM
#4
Thread Starter
Addicted Member
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);
-
Nov 4th, 2009, 01:33 AM
#5
Re: [RESOLVED] IPC remoting -- Share an object between two processes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|