Application.Run problem

  • Thread starter Thread starter Tom Edelbrok
  • Start date Start date
T

Tom Edelbrok

I posted this accidentally to dotnet.general, but it is a VB.NET problem, so
here it is again ...

With VB.NET in VS 2003 I am using "Sub Main()" as my startup object, and
from within Sub Main() I use "Application.Run(MyMainForm)". Essentially I am
starting my application and then displaying the form, rather than setting
the form as the startup object. This works great except for one major
problem ... I can't access any of the form's controls while in the debugger.
There is no problem accessing local variables in a procedure, but when I try
to access a label control on the form my machine hangs.

What causes this problem and how can I get around it?

It is very consistent - I can always display anything I want at a
breakpoint, except controls on the form. If I try to display them in the
immediate window my machine hangs.

Thanks,

Tom
 
not seeing how you are doing this in code makes a definitive answer in
cide, but three things quickly come to mind...
0) there must be an instance of the form created before you can access
the controls
Dim frm as New MyForm()
1) check the access level of the controls and the methods -- VB sets
things as Protected or Friend
2) this is a bug in Whidbey Beta 1 (I see this with other variables as
well -- something with the debugger -- the variables jump out of scope
before they really should -- a workaround solution is to print values to
the debug window)

Cheers.
 
Further testing shows that the problem occurs due to the use of a timer
object in my program. I have the following in my object's constructor:

moAutoResetEvent = New AutoResetEvent(True)

moIntervalStateTimer = New System.Threading.Timer(moTimerDelegate,
moAutoResetEvent, 0, mnScanIntervalMilliseconds)

If I comment out the lines that create the timer then I have no lockup
problems in the debugger. But with the timer included, as long as I don't
use the debugger the timer fires perfectly and everthing is happy.

Any ideas?

Thanks in advance,
Tom
 
Back
Top