/// <summary> /// Adds a value to the counter atomically. /// </summary> /// <param name="value">Value to add</param> /// <returns>The new value of the counter</returns> public int Add(int value) { var currentMachine = Runtime.GetCurrentMachine(); Runtime.SendEvent(CounterMachine, SharedCounterEvent.AddEvent(currentMachine.Id, value)); var response = currentMachine.Receive(typeof(SharedCounterResponseEvent)).Result; return((response as SharedCounterResponseEvent).Value); }
/// <summary> /// Adds a value to the counter atomically. /// </summary> public int Add(int value) { var currentMachine = this.Runtime.GetExecutingMachine <Machine>(); this.Runtime.SendEvent(this.CounterMachine, SharedCounterEvent.AddEvent(currentMachine.Id, value)); var response = currentMachine.Receive(typeof(SharedCounterResponseEvent)).Result; return((response as SharedCounterResponseEvent).Value); }