ocbeta
Member
Hello,
I have a quick question, I have a section of code that watches a directory and creates new thumbnails when a new picture is placed in the directory. However, I cannot do this because I get the error:
Controls created on one thread cannot be parented to a control on a different thread.
I setup an invoke method. However, when I created the delegates and so forth I got the same error. Like I was invoking a method that still was not on the same thread.
The section of code is as follows:
Public Sub AddThumbnail(ByVal strPath As String)
Dim intRnd As Double = 1
Dim imgImage As Image = Image.FromFile(strPath)
Dim File As FileInfo
Dim Thumbnail As Image = imgImage.GetThumbnailImage(50, 50, Nothing, Nothing)
Thumbnail.Save(strLocation & "job" & "-" & intRnd & ".jpg")
ImageList1.Images.Add(Image.FromFile(strPath))
Dim pic As New PictureBox()
pic.Image = Thumbnail
pic.Dock = DockStyle.Top
Panel2.Controls.Add(pic)
End Sub
Thanks for the help. I am not sure which way to go with this. I need to update Panel2. Again, Thanks for the help.
ocbeta
I have a quick question, I have a section of code that watches a directory and creates new thumbnails when a new picture is placed in the directory. However, I cannot do this because I get the error:
Controls created on one thread cannot be parented to a control on a different thread.
I setup an invoke method. However, when I created the delegates and so forth I got the same error. Like I was invoking a method that still was not on the same thread.
The section of code is as follows:
Public Sub AddThumbnail(ByVal strPath As String)
Dim intRnd As Double = 1
Dim imgImage As Image = Image.FromFile(strPath)
Dim File As FileInfo
Dim Thumbnail As Image = imgImage.GetThumbnailImage(50, 50, Nothing, Nothing)
Thumbnail.Save(strLocation & "job" & "-" & intRnd & ".jpg")
ImageList1.Images.Add(Image.FromFile(strPath))
Dim pic As New PictureBox()
pic.Image = Thumbnail
pic.Dock = DockStyle.Top
Panel2.Controls.Add(pic)
End Sub
Thanks for the help. I am not sure which way to go with this. I need to update Panel2. Again, Thanks for the help.
ocbeta