Folderbrowserdialog ContextSwitchDeadlock

I have had a problem resulting in ContextSwitchDeadlock and a consequent build up in memory use.

The following is a snippet which results in the error when using a Folderbrowserdialog control.

How can the ContextSwitchDeadlock be avoided?

PrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button1.Click

FolderBrowserDialog1.ShowDialog()

Dim tstartAsDouble

tstart = DateAndTime.Timer

DoWhile DateAndTime.Timer < tstart + 70.0

TextBox1.Text = DateAndTime.Timer - tstart

Refresh()

Loop

EndSub

[1456 byte] By [BWat] at [2007-12-24]
# 1
A

context switch deadlock is a fairly common problem with the IDE.

Be sure to test the release version so you know this isn't caused by

your program.

nobugz at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

I may have missed the whole point of what you

are talking about, but anyway, the following change

kept the UI from locking up and kept me from getting

a stack overflow.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

FolderBrowserDialog1.ShowDialog()

Dim tstart As Double

tstart = DateAndTime.Timer

Do While DateAndTime.Timer < tstart + 70.0

If (DateAndTime.Timer - tstart) Mod 0.25 = 0 Then

TextBox1.Text = CStr(DateAndTime.Timer - tstart)

Application.DoEvents()

Refresh()

End If

Loop

End Sub

TallDude at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Many thanks.

I had not recocognised the significance of the Application.doevents method.

BWat at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...