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 / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Use of Program.cs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeremy - 18 Jul 2006 18:43 GMT
I'm finally getting up to speed on VS 2005 and see that there is now a class
named Program that contains the main entry point for Windows Forms
applications. Yes, I understand that this is something that VS creates for
us and that we are not *required* to use it as is.

My question:
Are many of you who are writing non trivial Windows Forms applications
keeping this Program.cs file as generated by VS? Are you using it "as is" or
do you throw other things in there? If so, what else do you add to
Program.cs?

(just wondering what most developers think of this change and how you are
using it).

Thanks.
Nicholas Paldino [.NET/C# MVP] - 18 Jul 2006 18:53 GMT
Jeremy,

   Personally, I think it is a good thing, as it promotes encapsulation
(why have the startup code in the form?  It might not have anything to do
with that).

   I will add some code to that file easily, but in general, I think it is
better than the old template.

   In the end, it is a class in the project like any other.  You can modify
it how you wish.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> I'm finally getting up to speed on VS 2005 and see that there is now a
> class named Program that contains the main entry point for Windows Forms
[quoted text clipped - 11 lines]
>
> Thanks.
Mythran - 18 Jul 2006 18:56 GMT
> I'm finally getting up to speed on VS 2005 and see that there is now a
> class named Program that contains the main entry point for Windows Forms
[quoted text clipped - 11 lines]
>
> Thanks.

When I use VS2K5, I normally either keep Program.cs or change it to
something else (something that I've used is InternalMain, which is just the
same as Program.cs).  Inside this class I will normally have any
command-line argument parsing/functionality so that I can just have this
part done with before the rest of the app loads (forms).

But that's just me :)

HTH,
Mythran
Brian Gideon - 18 Jul 2006 19:01 GMT
Jeremy,

I think it's a good idea.  It provides a logical place to put entry
point code.  I have since started adopting the convention for 1.1
application as well.  I often tinker around with the code inside the
Main method like choosing to run the application as a windows service
or winform application, processing command line arguments, etc.

Brian

> I'm finally getting up to speed on VS 2005 and see that there is now a class
> named Program that contains the main entry point for Windows Forms
[quoted text clipped - 11 lines]
>
> Thanks.
Andy - 18 Jul 2006 19:03 GMT
Yup, except I added a bunch to it, like throwing up a splash screen,
loading some initail data from the database and kicking off some
background threads, all before I show the main form.

When the form closes, it then cleans everything up.

Andy

> I'm finally getting up to speed on VS 2005 and see that there is now a class
> named Program that contains the main entry point for Windows Forms
[quoted text clipped - 11 lines]
>
> Thanks.
Roger - 18 Jul 2006 20:01 GMT
BTW, this is just like the project file in Delphi (dpr).

It is a good clean way to start off and perform
application initialization and precondition checks.

Roger

Rate this thread:







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.