Connecting Tech Pros Worldwide Forums | Help | Site Map

Setting properties at design-time faster than at run-time?

Ronald S. Cook
Guest
 
Posts: n/a
#1: Oct 7 '06
In a .NET Windows app, if I set somehting like the title of the form to
"MyApp" at run-time, will that make the app run slightly slower than if I
had set the title at design-time?

Thanks,
Ron



Tom Shelton
Guest
 
Posts: n/a
#2: Oct 7 '06

re: Setting properties at design-time faster than at run-time?



Ronald S. Cook wrote:
Quote:
In a .NET Windows app, if I set somehting like the title of the form to
"MyApp" at run-time, will that make the app run slightly slower than if I
had set the title at design-time?
>
Thanks,
Ron
Ron,

I don't see how since the designer simply sets the property in code
anyway.

--
Tom Shelton

Robbe Morris [C# MVP]
Guest
 
Posts: n/a
#3: Oct 8 '06

re: Setting properties at design-time faster than at run-time?


The designer simply writes the code for you. There
is no real difference.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/..._generator.asp





"Tom Shelton" <tom@mtogden.comwrote in message
news:1160242910.482484.70230@c28g2000cwb.googlegro ups.com...
Quote:
>
Ronald S. Cook wrote:
Quote:
>In a .NET Windows app, if I set somehting like the title of the form to
>"MyApp" at run-time, will that make the app run slightly slower than if I
>had set the title at design-time?
>>
>Thanks,
>Ron
>
Ron,
>
I don't see how since the designer simply sets the property in code
anyway.
>
--
Tom Shelton
>

Tom Shelton
Guest
 
Posts: n/a
#4: Oct 8 '06

re: Setting properties at design-time faster than at run-time?



Robbe Morris [C# MVP] wrote:
Quote:
The designer simply writes the code for you. There
is no real difference.
>
That is what I was trying to say... Perhaps I was unclear.

--
Tom Shelton

Cor Ligthert [MVP]
Guest
 
Posts: n/a
#5: Oct 8 '06

re: Setting properties at design-time faster than at run-time?


Hi Op.

If you click on the designer generated code on the + in version 1.x or look
in the designer class if you put in top of the Solution Explorer "Show all
files" in the class with the name xx.designer.cs than you see the generated
code. That is mostly better than that you or I would do it by hand.

I thought Tom was pretty clear, but before somebode doubt in that.

:-))))))

Cor


"Tom Shelton" <tom@mtogden.comschreef in bericht
news:1160276666.661973.181100@e3g2000cwe.googlegro ups.com...
Quote:
>
Robbe Morris [C# MVP] wrote:
Quote:
>The designer simply writes the code for you. There
>is no real difference.
>>
>
That is what I was trying to say... Perhaps I was unclear.
>
--
Tom Shelton
>

Tigger
Guest
 
Posts: n/a
#6: Oct 9 '06

re: Setting properties at design-time faster than at run-time?


There can be a differences to designer and runtime setting of
properties.

If you look at the designer generated code it sometimes wraps
BeginInit() and EndInit() around the setting of a controls properties.
This is so the control can optimise the initialising of properties,
generally by delaying any actions on the property until the EndInit.

Also, setting at run time could be done too late thus causing something
like the title to be drawn twice.

I would recommend using the design time setting if possible.

Tigger


Cor Ligthert [MVP] wrote:
Quote:
Hi Op.
>
If you click on the designer generated code on the + in version 1.x or look
in the designer class if you put in top of the Solution Explorer "Show all
files" in the class with the name xx.designer.cs than you see the generated
code. That is mostly better than that you or I would do it by hand.
>
I thought Tom was pretty clear, but before somebode doubt in that.
>
:-))))))
>
Cor
>
>
"Tom Shelton" <tom@mtogden.comschreef in bericht
news:1160276666.661973.181100@e3g2000cwe.googlegro ups.com...
Quote:

Robbe Morris [C# MVP] wrote:
Quote:
The designer simply writes the code for you. There
is no real difference.
>
That is what I was trying to say... Perhaps I was unclear.

--
Tom Shelton
Cor Ligthert [MVP]
Guest
 
Posts: n/a
#7: Oct 9 '06

re: Setting properties at design-time faster than at run-time?


Tigger,

Maybe is that your intention, but it can be readed in another way.

The so called design time properties can also be used by code yourself.

Cor

"Tigger" <tony@grunt.tvschreef in bericht
news:1160352827.687585.170030@e3g2000cwe.googlegro ups.com...
Quote:
There can be a differences to designer and runtime setting of
properties.
>
If you look at the designer generated code it sometimes wraps
BeginInit() and EndInit() around the setting of a controls properties.
This is so the control can optimise the initialising of properties,
generally by delaying any actions on the property until the EndInit.
>
Also, setting at run time could be done too late thus causing something
like the title to be drawn twice.
>
I would recommend using the design time setting if possible.
>
Tigger
>
>
Cor Ligthert [MVP] wrote:
Quote:
>Hi Op.
>>
>If you click on the designer generated code on the + in version 1.x or
>look
>in the designer class if you put in top of the Solution Explorer "Show
>all
>files" in the class with the name xx.designer.cs than you see the
>generated
>code. That is mostly better than that you or I would do it by hand.
>>
>I thought Tom was pretty clear, but before somebode doubt in that.
>>
>:-))))))
>>
>Cor
>>
>>
>"Tom Shelton" <tom@mtogden.comschreef in bericht
>news:1160276666.661973.181100@e3g2000cwe.googlegr oups.com...
Quote:
>
Robbe Morris [C# MVP] wrote:
>The designer simply writes the code for you. There
>is no real difference.
>>
>
That is what I was trying to say... Perhaps I was unclear.
>
--
Tom Shelton
>
>

Tigger
Guest
 
Posts: n/a
#8: Oct 9 '06

re: Setting properties at design-time faster than at run-time?


Yes,

As you stated, you can see that the designer adds its own code to set
the properties.

And you can do the same. It just might not be as efficient as the code
the designer makes due to the reasons I made. (Don't directly edit the
designer code unless you know what you are doing as there's a good
chance your changes will be lost)

We have come across speed issues in our application due to runtime
setting of properties. Our solution was to follow the pattern used by
the designer and implement and use the IInitializable interface
(BeginInit, EndInit) for our own runtime code.

We also had problems with the gui re-drawing as you change properties,
which can be very slow. These issues can be quite complex to solve at
times.

However, I don't think the Title property is one that will suffer from
any speed issues.

Tigger

Cor Ligthert [MVP] wrote:
Quote:
Tigger,
>
Maybe is that your intention, but it can be readed in another way.
>
The so called design time properties can also be used by code yourself.
>
Cor
>
"Tigger" <tony@grunt.tvschreef in bericht
news:1160352827.687585.170030@e3g2000cwe.googlegro ups.com...
Quote:
There can be a differences to designer and runtime setting of
properties.

If you look at the designer generated code it sometimes wraps
BeginInit() and EndInit() around the setting of a controls properties.
This is so the control can optimise the initialising of properties,
generally by delaying any actions on the property until the EndInit.

Also, setting at run time could be done too late thus causing something
like the title to be drawn twice.

I would recommend using the design time setting if possible.

Tigger


Cor Ligthert [MVP] wrote:
Quote:
Hi Op.
>
If you click on the designer generated code on the + in version 1.x or
look
in the designer class if you put in top of the Solution Explorer "Show
all
files" in the class with the name xx.designer.cs than you see the
generated
code. That is mostly better than that you or I would do it by hand.
>
I thought Tom was pretty clear, but before somebode doubt in that.
>
:-))))))
>
Cor
>
>
"Tom Shelton" <tom@mtogden.comschreef in bericht
news:1160276666.661973.181100@e3g2000cwe.googlegro ups.com...

Robbe Morris [C# MVP] wrote:
The designer simply writes the code for you. There
is no real difference.
>

That is what I was trying to say... Perhaps I was unclear.

--
Tom Shelton
Closed Thread