Home All Groups Group Topic Archive Search About

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

Author
2 Mar 2006 10:04 PM
Michael.Suarez
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?

Author
2 Mar 2006 10:28 PM
Kevin Spencer
It should be expected.

--
HTH,

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


<Michael.Sua***@gmail.com> wrote in message
Show quote
news:1141337067.719081.227060@i39g2000cwa.googlegroups.com...
> 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?
>
Author
2 Mar 2006 10:36 PM
Michael.Suarez
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.
Author
3 Mar 2006 5:39 AM
Nick Hounsome
<Michael.Sua***@gmail.com> wrote in message
news:1141339006.874970.219640@e56g2000cwe.googlegroups.com...
> 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
}
Author
6 Mar 2006 3:27 PM
Michael.Suarez
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.

AddThis Social Bookmark Button