Help with stop - start of a loop

I have the following attached loop that runs through 300+ mil loops generated from 3 Lists of string.

District, inner & ending

Is there any way to save the current position from the "For each .. as string in .." and then load the position back in ? Just that I have an estimated run time of 500+ hours and would like to be able to resume from a stored position should I have to.

I am also opened to other ideas aswell :-)

Many Thanks
Steve

Dim District, Inner, Ending As New List(Of String)
District = DistrictList()
Inner = InnerList()
Ending = EndingList()
For Each d1 As String In District
s1 = d1
For Each i1 As String In Inner
s2 = s1 & i1
For Each e1 As String In Ending
s3 = s2 & " " & e1
While pauseLoop
System.Threading.Thread.Sleep(100)
Application.DoEvents()
End While
Application.DoEvents()
Next
Next
Next

let's assume that the Distrinctlist, InnerList and EndingList are sorted (if not, that will be "required")

then, you have only to check if the loop's control variable is after the starting value OR if the outer loops are on the next level (in which case all inner loops have to be processed)

Dim District, Inner, Ending As List(Of String)
Dim startDistrict As String = "" 'set the district to start processing from, leave empty to do it all
Dim startInner As String = "" 'idem
Dim startEnding As String = "" 'idem
District = DistrictList()
Inner = InnerList()
Ending = EndingList()
For Each d1 As String In District
If d1 >= startDistrict Then
s1 = d1
For Each i1 As String In Inner
if i1 >= startInner OR d1 > startDistrict then
s2 = s1 & i1
For Each e1 As String In Ending
if e1 >= startEnding or d1 > startDistrict or i1 > startInner then
s3 = s2 & " " & e1
While pauseLoop
System.Threading.Thread.Sleep(100)
Application.DoEvents()
End While
Application.DoEvents()
end if 'if e1 >= startEnding or d1 > startDistrict or i1 > startInner then
Next 'e1 As String In Ending
End if ' if i1 >= startInner OR d1 > startDistrict then
Next 'i1 As String In Inner
End if ' If d1 >= startDistrict Then
Next 'd1 As String In District

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Featured Post

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…