Click here to Skip to main content
16,008,750 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Combobox in Datagrid (windows) Pin
Justin Perez31-Jan-08 3:57
Justin Perez31-Jan-08 3:57 
GeneralRe: Combobox in Datagrid (windows) Pin
Jeminwins31-Jan-08 18:01
professionalJeminwins31-Jan-08 18:01 
GeneralRe: Combobox in Datagrid (windows) PinPopular
Justin Perez1-Feb-08 3:50
Justin Perez1-Feb-08 3:50 
GeneralRe: Combobox in Datagrid (windows) Pin
Mycroft Holmes1-Feb-08 17:18
professionalMycroft Holmes1-Feb-08 17:18 
QuestionVB.Net 2005 And Databinding Pin
ejaz_pk31-Jan-08 1:48
ejaz_pk31-Jan-08 1:48 
GeneralRe: VB.Net 2005 And Databinding Pin
pmarfleet31-Jan-08 8:51
pmarfleet31-Jan-08 8:51 
GeneralRe: VB.Net 2005 And Databinding Pin
Steven J Jowett31-Jan-08 8:52
Steven J Jowett31-Jan-08 8:52 
QuestionStack Overflow when adding controls across threads. Pin
Chinners30-Jan-08 23:25
Chinners30-Jan-08 23:25 
Hi all,

I have a bit of an issue with some code I am designing.

I am trying to implement a "file open" dialog for images. There are reasons for not wanting to use the standard dialogs. Also, I want the control to remain responsive whilst displaying a the list, so a user can select "up", or another folder whilst the list of preview images is loading.

To do this, I have a panel object, and my own "simpleimage" which is a simple control which has an image and a caption. I draw the a small preview thumbnail image to the simple control then add this to the panel.

To keep the app responsive, the creating of these simple images is done in a background worker, and a delegate adds them to the panel.

    Delegate Sub AddIconDelegate(ByVal s As SimpleImage)<br />
<br />
    Private Sub AddIcon(ByVal s As SimpleImage)<br />
        SyncLock Me.ImagePanel<br />
            Me.ImagePanel.Controls.Add(s)<br />
        End SyncLock<br />
    End Sub


and, in the background worker:
Loop through relevant images<br />
  Dim Blob As New SimpleImage(MyCL, ImageTypeEnum.Image, FileName, Cap)<br />
  AddHandler Blob.ImageSelected, AddressOf ImageSelectedHandler<br />
  Blob.Location = New Point(xp, yp)<br />
  Me.ImagePanel.Invoke(ASI, Blob)<br />
End Loop.


And the scrollbar:
Private Sub _ValueChanging(ByVal Sender As vScroller) Handles VS1.ValueChanging<br />
    SyncLock Me.ImagePanel<br />
        Me.ImagePanel.Top = -VS1.Value<br />
    End SyncLock<br />
End Sub



This code generally works fine. I have successfully added over 4000 images.

I can mess around with the scrollbar which controls the panels position (move it up and down) and generally things are fine, BUT if I go crazy and move the scroll bar really crazily, the invoked procedure (AddIcon), more specifically the "Me.ImagePanel.Controls.Add(s)" line, will cause a StackOverflowException. This can happen with only 300 icons.

So, Question time.
Does anyone know why this is happening?
Any way of catching the stackoverflow exception?


I have tried slowing the backgroundworker down with a thread.sleep, and this reduces the chance if it happening, but does not eliminate it. The synclock also reduces the chance of this happening.

Thanks in advance.

Jason
GeneralRe: Stack Overflow when adding controls across threads. Pin
m@u30-Jan-08 23:48
m@u30-Jan-08 23:48 
GeneralRe: Stack Overflow when adding controls across threads. Pin
Chinners31-Jan-08 0:16
Chinners31-Jan-08 0:16 
GeneralRe: Stack Overflow when adding controls across threads. Pin
m@u31-Jan-08 0:22
m@u31-Jan-08 0:22 
AnswerRe: Stack Overflow when adding controls across threads. Pin
Chinners31-Jan-08 0:31
Chinners31-Jan-08 0:31 
GeneralProblem with Excel Sheet name when importing using oledb Pin
RichardBerry30-Jan-08 21:28
RichardBerry30-Jan-08 21:28 
GeneralRe: Problem with Excel Sheet name when importing using oledb Pin
Johan Hakkesteegt31-Jan-08 0:47
Johan Hakkesteegt31-Jan-08 0:47 
GeneralRe: Problem with Excel Sheet name when importing using oledb Pin
RichardBerry31-Jan-08 3:58
RichardBerry31-Jan-08 3:58 
GeneralRe: Problem with Excel Sheet name when importing using oledb Pin
Johan Hakkesteegt31-Jan-08 20:30
Johan Hakkesteegt31-Jan-08 20:30 
GeneralRe: Problem with Excel Sheet name when importing using oledb Pin
RichardBerry1-Feb-08 0:50
RichardBerry1-Feb-08 0:50 
GeneralDeployment Problem Pin
SamRST30-Jan-08 21:21
SamRST30-Jan-08 21:21 
GeneralDay of the week combinations. [modified] Pin
Absenm30-Jan-08 20:45
Absenm30-Jan-08 20:45 
GeneralRe: Day of the week combinations. Pin
Mycroft Holmes30-Jan-08 21:55
professionalMycroft Holmes30-Jan-08 21:55 
QuestionDatagridview default style getting changed changes Pin
nishkarsh_k30-Jan-08 20:36
nishkarsh_k30-Jan-08 20:36 
GeneralRe: Datagridview default style getting changed changes Pin
Dave Kreskowiak31-Jan-08 4:46
mveDave Kreskowiak31-Jan-08 4:46 
GeneralRe: Datagridview default style getting changed changes Pin
nishkarsh_k31-Jan-08 19:48
nishkarsh_k31-Jan-08 19:48 
GeneralLock Folder Pin
Kumaran21cen30-Jan-08 19:43
Kumaran21cen30-Jan-08 19:43 
GeneralRe: Lock Folder Pin
Mycroft Holmes30-Jan-08 22:00
professionalMycroft Holmes30-Jan-08 22:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.