I have a for loop that loads a number of web user controls. These are then added to an array, i.e Dim i As Integer For i = 0 To XMLdv.Table.Rows.Count - 1 Try Dim panelCodeFilename As String = XMLdv.Table.Rows(i)("panelCode") Dim panelCodeControl As PartialCachingControl
= LoadControl(panelCodeFilename) panelCodeControl.EnableViewState = True panelcontrolsarray(XMLdv.Table.Rows(i)("id")) = panelCodeControl Catch exp As Exception testlabel1.Text += "
Error adding " & i & " " & exp.ToString testlabel1.Text += "
XML panel id = " & XMLdv.Table.Rows(i)("id") testlabel1.Text += "
Please make sure the panel is cached" End Try Next I want to try and do a thread with each one of these, but I dont want the code to continue until all the web user controls are loaded. Something along the lines of For all web user controls load user control
usng thread end for continue with code only if all threads have finished Can anyone give me suggestions on how to do this. Jagdip
I miss a time when programmers were real programmers, and not drag and drop artists!!
Just curious as to why you need it done in a thread if nothing else can continue on until the threads are finished... the point of threads are to allow your code to continue while your threads are processing. Sounds like you are still doing ordered steps so
I don't see why you would need a thread.
My problem is that, as I am loading about 20-30 web user controls, the page takes 25-30 seconds to load the first time. I thought that if I thread the for loop that loads these web user controls, the loading time would be decreased significantly. Of course
the problem then is that I dont actually want to add the web user control until it has been loaded. So I want seperate threads to load the web user controls, but I want my code to continue only after all the threads have finished. Any help would be greatly
appriciated. Jagdip
I miss a time when programmers were real programmers, and not drag and drop artists!!
You mention 'the page takes 25-30 seconds to load the first time. ' This is the nature of .NET. The first time after you compile your project will be the longest amount of time to bring back your page because of the initial compile. Subsequent calls to the
page should be quicker. I don't think you'll gain any speed advantage with your thread idea... Just an opinion... Jerry
jagdipa
Star
8583 Points
2015 Posts
threading inside a for loop
Aug 07, 2003 02:27 PM|LINK
Error adding " & i & " " & exp.ToString testlabel1.Text += "
XML panel id = " & XMLdv.Table.Rows(i)("id") testlabel1.Text += "
Please make sure the panel is cached" End Try Next I want to try and do a thread with each one of these, but I dont want the code to continue until all the web user controls are loaded. Something along the lines of For all web user controls load user control usng thread end for continue with code only if all threads have finished Can anyone give me suggestions on how to do this. Jagdip
Kelsey
Contributor
4222 Points
797 Posts
Re: threading inside a for loop
Aug 07, 2003 05:37 PM|LINK
jagdipa
Star
8583 Points
2015 Posts
Re: threading inside a for loop
Aug 08, 2003 08:25 AM|LINK
JerryK@PikeO...
Participant
1170 Points
234 Posts
Re: threading inside a for loop
Aug 08, 2003 11:37 AM|LINK