13.07.2015 Views

Remoting in C# and .NET - The Journal of Object Technology

Remoting in C# and .NET - The Journal of Object Technology

Remoting in C# and .NET - The Journal of Object Technology

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

REMOTING IN <strong>C#</strong> AND .<strong>NET</strong>List<strong>in</strong>g 2 - <strong>Remot<strong>in</strong>g</strong> application with a server <strong>and</strong> two GUI clientsus<strong>in</strong>g System;us<strong>in</strong>g System.Runtime.<strong>Remot<strong>in</strong>g</strong>;us<strong>in</strong>g System.Runtime.<strong>Remot<strong>in</strong>g</strong>.Channels;us<strong>in</strong>g System.Runtime.<strong>Remot<strong>in</strong>g</strong>.Channels.Http;us<strong>in</strong>g System.Thread<strong>in</strong>g;namespace <strong>Remot<strong>in</strong>g</strong> {public class TargetServer: MarshalByRef<strong>Object</strong> {// Fieldsprivate <strong>in</strong>t xPos, yPos; // position <strong>of</strong> mov<strong>in</strong>g rectangleprivate <strong>in</strong>t x, y; // position <strong>of</strong> shotprivate Thread thrd;private R<strong>and</strong>om rnd;// Constructorpublic TargetServer() {rnd = new R<strong>and</strong>om();for (<strong>in</strong>t i = 0; i < 50000; i++) {rnd.Next(100000);}thrd = new Thread(new ThreadStart(MovePosition));thrd.Start();}// Read-only propertiespublic <strong>in</strong>t XPOS {get {return xPos;}}public <strong>in</strong>t YPOS {get {return yPos;}}public <strong>in</strong>t X {get {return x;}}public <strong>in</strong>t Y {get {return y;}}90 JOURNAL OF OBJECT TECHNOLOGY VOL. 3, NO. 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!