// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; // remote object klasse // skal extende MarshalByRefObject public class Calc : MarshalByRefObject { // object nummer ud af total private int no; private static int total = 0; // synkroniserings objekt private object sync = new object(); // constructor som sætter objekt nummer public Calc() { lock(sync) { total++; no = total; } } // metoder der skal kaldes remote public int add(int a, int b) { return (a + b); } public int mul(int a, int b) { return (a * b); } // metode til at checke egenskaberne public string ID { get { return (no + " of " + total); } } }