473,503 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows Forms and Console Application

Hi --

I have a VB6 application that I plan on rewriting in C#.NET. The program
today basically connects to a SQL Server and parses varies system stats from
our mainframes and rolls the data up for up/downtime statistics, etc.

Since the current program today requires me to click various buttons and
tabs to load/review the information being parses and saved, I would like to
implement this applications as both a Windows Forms and Console application.
My thought was that I can run the Windows Form application like normal and
manually click buttons and stuff to perform the desired function. However,
I would also like the ability to run the .EXE via a scheduler, if needed, to
automated this process as well.

Can anybody provide me some points on how I can have both features in the
same application?

In addition, how can I check whether I'm running in console mode vs windows
mode in order to execute the correct events automatically?

Thanks for any help.

May 11 '06 #1
4 3480
Develop it as a normal Windows Application with your forms, buttons,
etc., but start it using a main method that will allow you pass command
line arguments. Then, based on the arguments passed, you can either
show the main form for manual operation or execute the code without
showing the main form based on the parameters passed in.

I wouldn't worry about using a true console app. A normal Windows app
should work. You will have to design it so the UI is separated from
the main functionality of the app so that you can execute the code both
from the UI and from the command line.

May 11 '06 #2

"dm1608" <dm****@spam.net> wrote in message
news:Op**************@TK2MSFTNGP02.phx.gbl...
Hi --

I have a VB6 application that I plan on rewriting in C#.NET. The program
today basically connects to a SQL Server and parses varies system stats
from our mainframes and rolls the data up for up/downtime statistics, etc.

Since the current program today requires me to click various buttons and
tabs to load/review the information being parses and saved, I would like
to implement this applications as both a Windows Forms and Console
application. My thought was that I can run the Windows Form application
like normal and manually click buttons and stuff to perform the desired
function. However, I would also like the ability to run the .EXE via a
scheduler, if needed, to automated this process as well.

Can anybody provide me some points on how I can have both features in the
same application?

In addition, how can I check whether I'm running in console mode vs
windows mode in order to execute the correct events automatically?

Thanks for any help.


I would put all the functionality into a non-GUI class and put that in a dll
and then write separate GUI and command line exes to use it. The advantage
of this is that you have the flexibility to add new GUIs or commandline
switches without changing the core stuff.
May 11 '06 #3
I've just done almost exactly this. Here's how...

Create a DLL that has the main engine which provides a class having methods
and properties as needed.

For long operations, provide an event that may be handled so that the engine
can suggest a good time to yield to the OS, such as calling
Application.DoEvents.

For command-line usage, load a console app that takes parameters and calls
the required methods on an instance of your engine class

for UI based usage, create an instance of the engine class, handle the yield
event if needed with a call to Application.DoEvents and create a Dialog
style front-end to drive the methods of the engine class instance.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"dm1608" <dm****@spam.net> wrote in message
news:Op**************@TK2MSFTNGP02.phx.gbl...
Hi --

I have a VB6 application that I plan on rewriting in C#.NET. The program
today basically connects to a SQL Server and parses varies system stats
from our mainframes and rolls the data up for up/downtime statistics, etc.

Since the current program today requires me to click various buttons and
tabs to load/review the information being parses and saved, I would like
to implement this applications as both a Windows Forms and Console
application. My thought was that I can run the Windows Form application
like normal and manually click buttons and stuff to perform the desired
function. However, I would also like the ability to run the .EXE via a
scheduler, if needed, to automated this process as well.

Can anybody provide me some points on how I can have both features in the
same application?

In addition, how can I check whether I'm running in console mode vs
windows mode in order to execute the correct events automatically?

Thanks for any help.

May 11 '06 #4
How --

Can you explain more about the events?

Most of what I will be doing will be SQL queries. Some take 10-15 secs...
others take 1-2 mins depending on how busy the SQL Server is. Is there a
way I can do events for this?

Also, how did you handle the checking of args and whether you're launching
or form or not?

Any help would be appreciated.


"Bob Powell [MVP]" <bob@_spamkiller_.bobpowell.net> wrote in message
news:eG**************@TK2MSFTNGP03.phx.gbl...
I've just done almost exactly this. Here's how...

Create a DLL that has the main engine which provides a class having
methods and properties as needed.

For long operations, provide an event that may be handled so that the
engine can suggest a good time to yield to the OS, such as calling
Application.DoEvents.

For command-line usage, load a console app that takes parameters and calls
the required methods on an instance of your engine class

for UI based usage, create an instance of the engine class, handle the
yield event if needed with a call to Application.DoEvents and create a
Dialog style front-end to drive the methods of the engine class instance.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"dm1608" <dm****@spam.net> wrote in message
news:Op**************@TK2MSFTNGP02.phx.gbl...
Hi --

I have a VB6 application that I plan on rewriting in C#.NET. The program
today basically connects to a SQL Server and parses varies system stats
from our mainframes and rolls the data up for up/downtime statistics,
etc.

Since the current program today requires me to click various buttons and
tabs to load/review the information being parses and saved, I would like
to implement this applications as both a Windows Forms and Console
application. My thought was that I can run the Windows Form application
like normal and manually click buttons and stuff to perform the desired
function. However, I would also like the ability to run the .EXE via a
scheduler, if needed, to automated this process as well.

Can anybody provide me some points on how I can have both features in the
same application?

In addition, how can I check whether I'm running in console mode vs
windows mode in order to execute the correct events automatically?

Thanks for any help.


May 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1623
by: Fred Iannon | last post by:
All, I have developed an application that needs to run in one of two modes: (1) IF NO command line parms are provided I would like it to run as a Window form application (i.e. /target:winexe)...
1
2568
by: James Carnley | last post by:
I am learning how to use windows forms and I have come across a small problem. Whenever I run my program it opens a console window before launching the windows form. The console doesnt go away...
6
3222
by: Mark Allison | last post by:
Hi, I have an application that I want to be to run in Console mode and GUI mode. If no params are entered, I want the GUI fired up, if params are entered, then go into console mode. I believe...
12
3729
by: Jarod_24 | last post by:
I got a project called "Forms" that hold some forms and stuff in my solution. A argument at startup defines wether to use a From or Console. My plan was to create a myConsole class that would...
8
18618
by: Alison | last post by:
Hi, Al I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window...
2
6509
by: Chris Dunaway | last post by:
I am attempting to use the AppDomain.UnhandledException event in a Windows Forms app and also in a Windows Service. But the event doesn't seem to be called. In a Windows Forms app, the event IS...
1
3797
by: lavu | last post by:
I currently have a C# windows Application . I would like this App to work through an command line interface also. I would like to specify command line params, which should start the app and process...
4
2046
by: dm1608 | last post by:
Hi -- I have a VB6 application that I plan on rewriting in C#.NET. The program today basically connects to a SQL Server and parses varies system stats from our mainframes and rolls the data up...
4
7984
by: Mo | last post by:
Hi, I am writing a console application to send a key sequence to an old clunky application on a regular interval using the windows scheduler. I can get it to work if it is a windows form...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.