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

  • Thread starter Thread starter Ronald S. Cook
  • Start date Start date
R

Ronald S. Cook

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
 
Ronald said:
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.
 
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/adonet_source_code_generator.asp
 
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
 
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
 
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 said:
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

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 said:
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.
 
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
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 said:
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

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" <[email protected]> schreef in bericht

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top