/// <summary> /// /// </summary> public void PrintTimeAndThreadAndValue() { const int mLoopTimes = ConstNumberValue.Five; const int mParallelCount = ConstNumberValue.Ten; //arrange bool mActual1 = false; //act CheckSeedValuesNoDuplicate(); Parallel.For(ConstValue.StartIndex, mParallelCount, i => { for (int j = ConstValue.StartIndex; j < mLoopTimes; ++j) { Debug.WriteLine(StringHelper.DefaultJoin(TimeHelper.GetTimeNowByPreprocessor().Ticks, ThreadLocalInformation.GetCreationTime().Ticks, ThreadLocalInformation.GetUniqueID(), i, j, PortableThreadSafeRandom.GetInstance().Next())); } }); mActual1 = PortableThreadSafeRandom.CheckSeedValuesNoDuplicate(); Debug.WriteLine(StringHelper.DefaultJoin(ThreadLocalInformation.GetCreationTimeValues().Count, string.Join(", ", ThreadLocalInformation.GetCreationTimeValues()))); Debug.WriteLine(StringHelper.DefaultJoin(ThreadLocalInformation.GetGuidValues().Count, string.Join(", ", ThreadLocalInformation.GetGuidValues()))); Debug.WriteLine(StringHelper.DefaultJoin(ThreadLocalInformation.GetUniqueIDValues().Count, string.Join(", ", ThreadLocalInformation.GetUniqueIDValues()))); if (!mActual1) { for (int i = ConstValue.StartIndex; i < ThreadLocalInformation.GetUniqueIDValues().zzGetLastIndex(); ++i) { for (int j = (i + ConstNumberValue.One); j < ThreadLocalInformation.GetUniqueIDValues().Count; ++j) { if (j == i) { Debug.WriteLine(StringHelper.DefaultJoin(i, j, ThreadLocalInformation.GetUniqueIDValues()[i])); } } } } //assert Contract.Assert(mActual1); }
/// <summary> /// /// </summary> public void CheckSeedValuesNoDuplicate() { const int mLoopTimes = ConstNumberValue.Twenty; const int mParallelCount = ConstNumberValue.Twenty; //arrange bool mActual1 = false; //act for (int i = ConstValue.StartIndex; i < mLoopTimes; ++i) { Parallel.For(ConstValue.StartIndex, mParallelCount, j => { PortableThreadSafeRandom.GetInstance().Next(); }); } mActual1 = PortableThreadSafeRandom.CheckSeedValuesNoDuplicate(); Debug.WriteLine(StringHelper.DefaultJoin(ThreadLocalInformation.GetCreationTimeValues().Count, string.Join(", ", ThreadLocalInformation.GetCreationTimeValues()))); Debug.WriteLine(StringHelper.DefaultJoin(ThreadLocalInformation.GetGuidValues().Count, string.Join(", ", ThreadLocalInformation.GetGuidValues()))); Debug.WriteLine(StringHelper.DefaultJoin(ThreadLocalInformation.GetUniqueIDValues().Count, string.Join(", ", ThreadLocalInformation.GetUniqueIDValues()))); if (!mActual1) { for (int i = ConstValue.StartIndex; i < ThreadLocalInformation.GetUniqueIDValues().zzGetLastIndex(); ++i) { for (int j = (i + ConstNumberValue.One); j < ThreadLocalInformation.GetUniqueIDValues().Count; ++j) { if (j == i) { Debug.WriteLine(StringHelper.DefaultJoin(i, j, ThreadLocalInformation.GetUniqueIDValues()[i])); } } } } //assert Contract.Assert(mActual1); }