Sets the global interval (for example, 0-1000). There is a write method that takes an interval from 0 to 200, as well as a string (denoted by S ). String S generated within a few minutes (generation goes to several threads), saves all strings to the list variable of the List<string>
I need to call the write method in several threads, sending it an interval after an interval (0-200, 200-400, etc.), as well as a new string S
I did this:
globalto = 1000; globalfrom = 0; double k = (globalto - globalfrom) ; k /= 200; if (k > Math.Truncate(k)) k = Math.Truncate(k) + 1; long[] mas = new long[Convert.ToInt32(k)]; for (int i = 0; i < k; i++) mas[i] = globalfrom += 200; mas.AsParallel().WithDegreeOfParallelism(thread).ForAll(j => write(j - 200, j, "")); But here I am not sending the string S I donβt know how to implement correctly so that as soon as a string appears in the list variable, a thread is immediately created that will call the write method, sending the current row and a new segment, and so that all this continues until the end of the global interval is reached (0- 1000).