Перевод из консольного приложения в форму - C#

Узнай цену своей работы

Формулировка задачи:

Здравствуйте Помогите,пожалуйста,перевести консольное приложение в форму. вот код программы в консоле
Листинг программы
  1. class StrSearch
  2. {
  3. public static string FilePatch;
  4. static string Str;
  5. static int StrCount;
  6. static string FileSize;
  7. static string GetSizeInString(string FilePatch)
  8. {
  9. System.IO.FileInfo File = new System.IO.FileInfo(FilePatch);
  10. long size = File.Length;
  11. string[] postfix = { "байт", "Kb", "Mb", "Gb", "Tb" };
  12. int i = 1;
  13. double temp = (double)size;
  14. while ((temp /= 1024) > 1024 && i++ < postfix.Length) ;
  15. return String.Format("{0:F}", temp) + " " + postfix[i];
  16. }
  17. static int GetLineString(string FilePatch)
  18. {
  19. int StrCount = 0;
  20. using (FileStream fStream = new FileStream(FilePatch, FileMode.Open))
  21. {
  22. if (fStream.Length != 0)
  23. {
  24. int b;
  25. StrCount = 1;
  26. while ((b = fStream.ReadByte()) != -1)
  27. {
  28. if (b == 10)
  29. {
  30. ++StrCount;
  31. }
  32. }
  33. }
  34. }
  35. return StrCount;
  36. }
  37. static void Main(string[] args)
  38. {
  39. Process thisProc = Process.GetCurrentProcess();
  40. thisProc.PriorityClass = ProcessPriorityClass.RealTime;
  41. //Console.WriteLine("Enter File:");
  42. FilePatch = @"1.txt";
  43. Console.WriteLine("Enter Str:");
  44. Str = Console.ReadLine();
  45. // Create new stopwatch
  46. Stopwatch stopwatch = new Stopwatch();
  47. // Begin timing
  48. stopwatch.Start();
  49. StrCount = GetLineString(FilePatch);
  50. FileSize = GetSizeInString(FilePatch);
  51. Console.Clear();
  52. Console.Write(" [" + FilePatch + " = " + StrCount + " str, " + FileSize + "]");
  53. int ThreadsCount = 1;
  54. Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
  55. Thread[] ThreadS;
  56. ThreadS = new Thread[ThreadsCount];
  57. for (int i = 0; i < ThreadsCount; i++)
  58. {
  59. ThreadS[i] = new Thread((research)); ThreadS[i].Start();
  60. }
  61. // Stop timing
  62. stopwatch.Stop();
  63. // Get the elapsed time as a TimeSpan value.
  64. TimeSpan ts = stopwatch.Elapsed;
  65. // Format and display the TimeSpan value.
  66. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
  67. ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
  68. Console.WriteLine("\n RunTime " + elapsedTime);
  69. }
  70. static void research()
  71. {
  72. while (true)
  73. {
  74. try
  75. {
  76. var StrLine = new StrSearchC();
  77. if (StrLine.Contains(Str) == true)
  78. Console.Write("\n [Found]: " + Str);
  79. else if (StrLine.Contains(Str) == false)
  80. Console.Write("\n [Not Found]: " + Str);
  81. Console.Write("\n Нажмите любую клавишу для завершения.....");
  82. Console.ReadLine();
  83. Console.Clear();
  84. break;
  85. }
  86. catch (ThreadAbortException)
  87. {
  88. break;
  89. }
  90. catch (Exception ex)
  91. {
  92. continue;
  93. }
  94. }
  95. }
  96. }
  97.  
  98. class StrSearchC
  99. {
  100. private HashSet<string> StrTable;
  101. public StrSearchC()
  102. {
  103. var StrSearchNumbersFromFile = File.ReadLines(StrSearch.FilePatch);
  104. StrTable = new HashSet<string>(StrSearchNumbersFromFile);
  105. }
  106. public bool Contains(string value)
  107. {
  108. return StrTable.Contains(value);
  109. }
  110. }
При переводе застрял на функции static void research()

Решение задачи: «Перевод из консольного приложения в форму»

textual
Листинг программы
  1. Process thisProc = Process.GetCurrentProcess();
  2. thisProc.PriorityClass = ProcessPriorityClass.RealTime;

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

8   голосов , оценка 4 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы