/// <summary> /// Get next random number using RandomService. /// </summary> /// <param name="maxValue">Maximum value for number.</param> /// <returns>The random number between zero and maxValue.</returns> private static int GetNextRandom(int maxValue) { #if !PORTABLE byte[] bytes = new byte[4]; lock (RandomServiceLock) { RandomService.GetNonZeroBytes(bytes); } return((int)Math.Round(((double)BitConverter.ToUInt32(bytes, 0) / uint.MaxValue) * (maxValue - 1))); #else return(RandomService.Next(maxValue)); #endif }