Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Bizarre behavior in design mode when inheriting from a form with a timer.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael.Suarez@gmail.com - 02 Mar 2006 22:04 GMT
this is so bizarre. Try it for yourself.

In VS 2005:
Create a windows control library with 1 form. The only control on the
form is 1 enabled timer whose tick event has MessageBox.Show("hello");

Build this library, and reference it from another windows form
application. Now create an inherited form, inheriting from the form you
just created.

What you will witness is this:

While you have the Windows App project open, in design mode, somehow
the timer will be ticking and it's tick event will get raised. And you
will actually see the message box pop up while you are in design mode!!

Can anyone explain why this happens?
Should this be expected? or is this a major bug?
Kevin Spencer - 02 Mar 2006 22:28 GMT
It should be expected.

Signature

HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
A brute awe as you,
a Metallic hag entity, eat us.

> this is so bizarre. Try it for yourself.
>
[quoted text clipped - 14 lines]
> Can anyone explain why this happens?
> Should this be expected? or is this a major bug?
Michael.Suarez@gmail.com - 02 Mar 2006 22:36 GMT
Is there any way to prevent it?
The timer I created is meant to be running when the application is
running, not when its in design mode.
Nick Hounsome - 03 Mar 2006 05:39 GMT
> Is there any way to prevent it?
> The timer I created is meant to be running when the application is
> running, not when its in design mode.

if( !DesignMode )
{
   // start timer
}
Michael.Suarez@gmail.com - 06 Mar 2006 15:27 GMT
Thanks!

What threw me off is that I wasn't expecting the code from the base
form to be executed while in design mode. I assumed code was only meant
to be executed at run time. But being as you can control what gets
executed at design time by using this.DesignMode, it's a cool feature.

One note about using this.DesignMode in is, at least what i was
experiencing, that DesignMode will always be false when you are
checking it from the constructor. Therefore, I had to check for
DesignMode in the Load event of the form.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.