473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Application Context

Hi,

I have an application that has a form and a few classes. Rather than the
form being the startup object "Application.Run(new Form1())", I would like
one of the classes to be the startup.
The startup class would then contain an instance of the form, to use as it's
UI.

To do this (and correct me if I'm wrong), I believe I need to create an
ApplicationContext object, and pass that to the Application.Run() method?

If so, does anyone have a sample of doing this, or some skeletal code? I
can't seem to find very good examples on the web. Which usually means I
might be on the wrong track...

TIA,
Norvin
Nov 15 '05 #1
5 8997
Norvin Laudon wrote:
I have an application that has a form and a few classes. Rather than the
form being the startup object "Application.Run(new Form1())", I would like
one of the classes to be the startup.
The startup class would then contain an instance of the form, to use as it's
UI.

To do this (and correct me if I'm wrong), I believe I need to create an
ApplicationContext object, and pass that to the Application.Run() method?

If so, does anyone have a sample of doing this, or some skeletal code? I
can't seem to find very good examples on the web. Which usually means I
might be on the wrong track...


I assume that what you want is to avoid application exit when main form
is closed. You can get example here:
http://www.nedcomp.nl/support/origdo...classtopic.htm

Nov 15 '05 #2
Hi Vad,

Thanks for the link, but it just links to the MSDN "ApplicationContext"
topic in the documentation. Did you send the wrong link?

It seems wrong to me to have an application whose UserInterface (a form!) is
the parent of all the various classes in the project. Is this unusual?

Thanks,
Norvin

"Vadim Chekan" <re*****************@rogers.com> wrote in message
news:vl*******************@news01.bloor.is.net.cab le.rogers.com...
Norvin Laudon wrote:
I have an application that has a form and a few classes. Rather than the
form being the startup object "Application.Run(new Form1())", I would like one of the classes to be the startup.
The startup class would then contain an instance of the form, to use as it's UI.

To do this (and correct me if I'm wrong), I believe I need to create an
ApplicationContext object, and pass that to the Application.Run() method?
If so, does anyone have a sample of doing this, or some skeletal code? I
can't seem to find very good examples on the web. Which usually means I
might be on the wrong track...
I assume that what you want is to avoid application exit when main form
is closed. You can get example here:

http://www.nedcomp.nl/support/origdo...classtopic.htm

Nov 15 '05 #3
Norvin Laudon wrote:
Hi Vad,

Thanks for the link, but it just links to the MSDN "ApplicationContext"
topic in the documentation. Did you send the wrong link?
It is different from the one on microsoft site in that it contains
example of usage of context to create application with more flexible
exit control.
It seems wrong to me to have an application whose UserInterface (a form!) is
the parent of all the various classes in the project. Is this unusual?


Why? I believe that 90% of all applications fillow to "main window"
conception. when you open a Word, a Outlook, <anything else here>, you
have a main window, and usually some child windows, or MDI.

If you tell what you want to achive in a long run, it would be easier to
give advice because "I would like one of the classes to be the startup"
barely can be the goal, rather a way to achive the goal :)

Vadim Chekan.

Nov 15 '05 #4
Hi Vad,

Thanks for taking the time to respond.

"Vadim Chekan" <re*****************@rogers.com> wrote in message
news:RoDub.22472
It is different from the one on microsoft site in that it contains
example of usage of context to create application with more flexible
exit control.

Sorry, I didn't realize it was different than MSDN, I'll take another look
at it...
It seems wrong to me to have an application whose UserInterface (a form!) is the parent of all the various classes in the project. Is this unusual?


Why? I believe that 90% of all applications fillow to "main window"
conception. when you open a Word, a Outlook, <anything else here>, you
have a main window, and usually some child windows, or MDI.

If you tell what you want to achive in a long run, it would be easier to
give advice because "I would like one of the classes to be the startup"
barely can be the goal, rather a way to achive the goal :)


OK, some details: I'm programming an application that interfaces with a
piece of machinery. The machine places items under an xray camera and
signals my program.
My program then snaps a picture of the items, and sends them off across the
network (via remoting) to a server. Sometime later, a decision on the image
comes back from the server, which my program then relays back to the
machinery.

In other words, there is very little human interaction. The UI is just there
for displaying a few status items for troubleshooting. All of the logic is
activated by other devices external to the program (the server, or the
machinery)

It would make sense to me to structure the program in the following way:
- have a main class (the startup class) which oversees all of the logic,
keeps track of what's been sent where, etc
- as members of this main class, have child classes to interface to the
server, the machine, and also a child class (form) for the UI

Do you agree with this general structure?

(As I typed this message, I realize that my typical application probably
differs from most in here, as there is typically no user interaction
required)

Thanks,
Norvin


Vadim Chekan.

Nov 15 '05 #5
> OK, some details: I'm programming an application that interfaces with a

[cut]
(As I typed this message, I realize that my typical application probably
differs from most in here, as there is typically no user interaction
required)


Well, now i see the point. You want to implement mostly windowless
application. Then ApplicationContex should be solution and I hope link I
gave you help.

But consider how user will call you application if he will want it. Or
how user will be able to shutdown (restart) your application. Probably
icon in notification area? Then I see it as something like this:
-----------------------
Form1 f = new Form1();
ApplicationContext cx = new ApplicationContext();
f.notifyIcon1.Click += new EventHandler(f.notifyIcon1_MouseDown);
Application.Run(cx);
---------------------
Then there will be no window (main window) after application start, only
icon in a notify area, and user will be able to call window only when
needed.

Vadim Chekan.

Nov 15 '05 #6

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

Similar topics

0
by: Sivashankaran Vaidhyalingam | last post by:
Hi folks, I have an aspx application App A hosted in a server which is inside the intranet . I need to serve pages from this application _through_ another application App B which acts as a proxy...
2
by: Uchiha Jax | last post by:
Hi, Recently had an issue with the Audio object from Microsoft.DirectX.AudioVideoPlayback. None of the events were firing from the object during tests (NUnit or Console). Knowing I had it...
0
by: Brett | last post by:
I am working with vb.net in a asp.net application. I have created a config file in xml format. The goal is to be able to change the config file without having to recompile the entire...
4
by: Hari Koduru | last post by:
Hi All, I am getting the following exception in an ASP.NET application. Exception Details: System.InvalidOperationException: Application is restarting. I have been to the following Support...
5
by: Martin Robins | last post by:
I have never dabbled with ASP.NET until now so be warned! I have created a web application with the single default form: WebForm1.aspx and when I try to display it I get this error. My...
0
by: pamelafluente | last post by:
I have implemented an example of HttpHandler to talk with my Windows application running on the server. I want to send some command (to do something) from IE (client) to my program running on...
4
by: Karl | last post by:
Hi all, I want to write an application that is launched from the context menu in Windows Explorer/Computer. That is to say, when I am browsing around my hard drive and get to any location I...
4
by: Andrus | last post by:
For winforms application with multiple related forms it is reasonable to create Linq database context object in start of application. Context object is released only when application exits. So...
0
by: =?Utf-8?B?UG9sbHkgQW5uYQ==?= | last post by:
Hi, I have previously used EL v 3.1 Exception Handling application block successfully. I thought I would now try to do the same with EL v 4.0. My first experiment was to replace an exception....
0
by: Steve | last post by:
Hello- Your assistance with this issue is greatly appreciated. Environment: - Load-balanced IIS 6.0 servers (Win2003) - web servers point (via UNC path) to a Microsoft File Cluster on...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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,...
0
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...

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.