I am creating an image gallery in VS2008 where each image is streamed from the web using the following code..
However the problem is that the user cannot interact with the form until each image has loaded (when the loop ends). Ideally I would like to be able to select an image before the following 20+ have loaded otherwise the user could be sitting around for a good 5 minutes even though they may only want to select the first image lol :S
Any ideas are much appreciated
VB.NET:
Public Sub LoadImageFromUrl(ByRef url As String, ByVal pb As PictureBox)
Dim request As Net.HttpWebRequest = DirectCast(Net.HttpWebRequest.Create(url), Net.HttpWebRequest)
Dim response As Net.HttpWebResponse = DirectCast(request.GetResponse, Net.HttpWebResponse)
Dim img As Image = Image.FromStream(response.GetResponseStream())
response.Close()
pb.SizeMode = PictureBoxSizeMode.StretchImage
pb.Image = img
End Sub
VB.NET:
Private Sub Button1_Click
Dim Y As Integer = 0
For i = 0 To 2
Dim thumb As New PictureBox
With thumb
.Size = New System.Drawing.Size(300, 100)
.Location = New System.Drawing.Point(2, Y)
.Name = "thumb" & i
Select Case i
Case 0
LoadImageFromUrl("http://picture0.jpg", thumb)
Case 1
LoadImageFromUrl("http://picture1.jpg", thumb)
Case 2
LoadImageFromUrl("http://picture2.jpg", thumb)
End Select
Controls.Add(thumb)
End With
Y += 200
Next i
End Sub
However the problem is that the user cannot interact with the form until each image has loaded (when the loop ends). Ideally I would like to be able to select an image before the following 20+ have loaded otherwise the user could be sitting around for a good 5 minutes even though they may only want to select the first image lol :S
Any ideas are much appreciated