Hi all,
I am making a VB .NET application,
there is a picturebox on the form in which i want to chnge images of a logo so it animates.
this is hapening in a separate thread adressof ChangeLogo..I update picturebox on a form trough a delegate.
Does anyone know what I am doing wrong that this thread is causing a memory leak?
Thanks.
Best regards,
Grega
I am making a VB .NET application,
there is a picturebox on the form in which i want to chnge images of a logo so it animates.
this is hapening in a separate thread adressof ChangeLogo..I update picturebox on a form trough a delegate.
Does anyone know what I am doing wrong that this thread is causing a memory leak?
Thanks.
Best regards,
Grega
VB.NET:
Private Sub ChangeLogo()
Dim logo As Image
Dim logonumber1 As New System.Text.StringBuilder
Do
logonumber1.Remove(0, logonumber1.Length)
logonumber1.Append("Logo")
logonumber1.Append(k.ToString.PadLeft(2, "0"))
logo = CType(My.Resources.Resources.ResourceManager.GetObject(logonumber1.ToString), System.Drawing.Bitmap)
PictureBoxVisible(Me.PictureBox2, logo)
Thread.Sleep(50)
k += 1
k = k Mod 20
Loop
End Sub
Dim PictureBoxVisible1 As PictureBoxVisibleDelegate
Private Sub PictureBoxVisible(ByVal ctr As Control, ByVal img As Image)
If ctr.InvokeRequired Then
PictureBoxVisible1 = New PictureBoxVisibleDelegate(AddressOf PictureBoxVisible)
Invoke(PictureBoxVisible1, ctr, img)
Else
Dim pbx As PictureBox
If TypeOf (ctr) Is PictureBox Then
pbx = ctr
pbx.Image = img
End If
ctr.Visible = True
End If
End Sub
Last edited by a moderator: