private void ViewInitAlphaNumericIdentifier(object sender, EventArgs e) { try { IdController.InitAlphaNumericIdentifier(_view.AlphaNumericIdentifier); ShowMessage($"ID изменен на {IdController.Identifier}"); } catch (Exception exception) { ShowError($"ќшибка: {exception.Message}"); } }
private void Increment(CancellationToken token) { //var stringA = TestHelper.LoadStringNumber("stringA.txt"); //var stringB = TestHelper.LoadStringNumber("stringB.txt"); string stringA; string stringB; TestHelper.GetRandomStringNumber((long)(1024 * 1024 * 1024 / 2), out stringA, out stringB); IdController.InitAlphaNumericIdentifier(_alphaNumericIdentifier); IdController.Increment(stringA, () => token.IsCancellationRequested); IdController.Increment(stringB, () => token.IsCancellationRequested); }
public void Test_Inrement(string id, string baseValue, string incrementValue, string resultId) { var sw = new Stopwatch(); sw.Start(); IdController.InitAlphaNumericIdentifier(_alphaNumericIdentifier); IdController.Increment(baseValue); IdController.Increment(incrementValue); sw.Stop(); Assert.AreEqual(resultId, IdController.Identifier); Console.WriteLine($"Numbers sum was done, Time: {sw.Elapsed}"); }
public void Test_LoadAsyncTest() { var mre = new ManualResetEvent(false); Console.WriteLine("Test_LoadTest BEGIN"); var sw = new Stopwatch(); sw.Start(); var incrementValue = "922337203685477"; IdController.InitAlphaNumericIdentifier(_alphaNumericIdentifier); CancellationTokenSource cancelTokenSource = new CancellationTokenSource(); var tf = new TaskFactory(cancelTokenSource.Token); tf.StartNew(() => { try { Console.WriteLine($"Begin load stringNumber, Time: {sw.Elapsed}"); sw.Restart(); //string stringA = TestHelper.LoadStringNumber("stringA.txt"); //string stringB = TestHelper.LoadStringNumber("stringB.txt"); string stringA; string stringB; TestHelper.GetRandomStringNumber((long)(1024 * 1024 * 100), out stringA, out stringB); Console.WriteLine($"StringNumber loaded, Time: {sw.Elapsed}"); sw.Restart(); IdController.Increment(stringA); Console.WriteLine($"Increment valueA was done, Time: {sw.Elapsed}"); sw.Restart(); IdController.Increment(stringB); Console.WriteLine($"Increment valueB was done, Time: {sw.Elapsed}"); sw.Restart(); mre.Set(); } catch (Exception e) { Console.WriteLine(e); mre.Set(); } }, cancelTokenSource.Token); tf.StartNew(() => { IncrementAction("Increment1", incrementValue, cancelTokenSource.Token); }, cancelTokenSource.Token); tf.StartNew(() => { IncrementAction("Increment2", incrementValue, cancelTokenSource.Token); }, cancelTokenSource.Token); mre.WaitOne(); cancelTokenSource.Cancel(); sw.Stop(); Console.WriteLine($"Numbers sum was done, Time: {sw.Elapsed}"); Console.WriteLine("Test_LoadTest END"); }