The Distributed Extensions library for .NET allows you to easily write distributed applications in C# without dealing with networking, synchronization, serialization or caching. You write your applications like you would any other and the library takes care of the rest.
Code Example
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
namespace Application.PeerToPeer { [Distributed(Mode.PeerToPeer)] class Program { public static void Main(string[] args) { // Set up distributed node. LocalNode node = new LocalNode(); node.Join(); // Get the universe and increase it's counter. Universe universe = new Distributed<Universe>("universe"); universe.Enter(); // Output the counter. Console.WriteLine("The universe counter is now at: " + universe.Counter); // Wait until the user hits enter. Console.WriteLine("Hit enter to quit at any time."); Console.ReadKey(true); universe.Leave(); // Quit. node.Leave(); return; } } [Distributed] public class Universe { /// <summary> /// The universe's counter. /// </summary> public int Counter { get; private set; } public void Enter() { this.Counter += 1; } public void Leave() { this.Counter -= 1; } } } |

