Can a c# app share memory (or variables/classes) with antoher c# app?
for example program A is a c# pinball game. can program B read the current score of program A pinball while playing? i know this can be accomplished by program A saving its score to a file on the hd every 4 seconds or so and program B reading this file every 4 seconds and updating the user interface, but there just be a way program B can just read the variables in program A. cheers all!
Mike GoldPosted Feb 12, 2006, 12:32 AM
AnttiPosted Feb 11, 2006, 8:35 AM
Rob JonesPosted Feb 10, 2006, 5:49 AM
AnttiPosted Feb 10, 2006, 5:31 AM
Well, not directly since they operate in different application domains. The best solution i can figure would be the Client/Server architecture. You could make the pinball game as a client, and the other program as a server program, and communicate between them normally through network (well, through your very local "network" when using "locahost" as an address).
You have to options:
1) Client A can SEND its score to the Server B, or
2) Server B can POLL the client A for scores after some time intervals.
I think the way 1) is better, so the server don't have to know about the existence of the client(s), they could just collect the results. You could make a special data sructure that you transfer in every update:
struct PinballDataPacket{
public double Score;
public int ClientId;
public string PlayerName;
}
That's just an example. But you can easily transfer these "packets" between client and server.
This is lots of faster way than saving to file, and also provides you the capability to locate the programs to different mahcines, when just assigning different network addresses. You could collect results from multiple clients at the same time, and put up a little contest in a lanparty;)