The GW-Scripting list is a discussion list for information regarding the development and use of Window-Eyes scripts. Any subscriber of the GW-Scripting list has the ability to post on-topic messages.

From:

 "BT" <b2me@fltg.net>

Subject:

 Re: .net Script Run() VS run( ApplicationContext ) question

Date:

 Sat, Apr 14, 2012 12:40:48 pm
This is a multi-part message in MIME format.

------=_NextPart_000_0015_01CD1A3B.D1BCB3D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Rick,

Read this and I think you get the idea.
Bruce

MSDN Blogs
>
jfo's coding
>
Starting an application without showing a form
Starting an application without showing a form
4232/ProfileUrlRedirect.ashx
jfoscoding
24 Aug 2005 10:23 AM
3
There were a lot of good comments/questions about keeping your UI responsive, if
you're interested in threading/application contexts etc,
it's worth a peek
..
I thought I'd rehash something today I've already talked about, but it is buried
in my
how to build notify icon (system tray) applications article
, and I think it's worthy of it's own coverage here: how to run an application without
showing a form
Dissecting Application.Run
If you have created a Windows Forms application, you may have happened across this
line in Main:
Application.Run(new Form1());
Magically, after calling this, the Form appears and events start firing left and
right. Here's what is actually happening, not quite so magically:
//Taking a microscope to Application.Run -
//create the form, and call initialize component
Form1 form1 = new Form1();
// create an application context
ApplicationContext applicationContext = new ApplicationContext();
// Set applicationContext.MainForm so that
// when form1 closes, exit the application context
applicationContext.MainForm = form1;
// Call Application.Run which will
// - call applicationContext.MainForm.Show()
// - begin processing events
Application.Run(applicationContext);
From this code, we can intuit that the ApplicationContext defines when the Application
should exit. In fact the point of all the overloads to Application.Run is to help
the Application know when to quit.
Running an application without showing a form
There are really two options here:
Instead of calling Application.Run with an argument, call Application.Run() to start
processing messages with NO arguments, then Application.Exit() when finished. This
is not very elegant as a missed call to Application.Exit means your application will
keep running even though there is no UI present.
A much cleaner solution is to inherit from the application context class and redefine
when you think the application should quit. The second solution is
covered in depth with sample here
..
Windows Forms
Share on Facebook
Share on Twitter
Share on Digg
Share on del.icio.us
More
Comments
Loading...
© 2012 Microsoft Corporation.
Terms of Use
Trademarks
Privacy Statement
Report Abuse
5.6.402.223

----- Original Message -----
From: RicksPlace
To: gw-scripting@gwmicro.com
Sent: Saturday, April 14, 2012 9:22 AM
Subject: .net Script Run() VS run( ApplicationContext ) question


Hi Aaron et al.
Is there any advantage of starting a Vb.net Script using Run( ApplicationContext) versus Run() method?
I have tested them and They both work but I am wondering about if either would be more robust when taking the fact that WindowEyes, a ThirdParty Application like VWD and the vb.net script are running at the same time.
I have not found any articles yet on if running in a new ApplicationContext class would help or hinder cross messaging, thread priorities and, or, all that other Systems Programmer heavy weight stuff.
As far as I can tell it just specifies another class to use in place of a form and watches for exiting of that class in this case.
Does that sound right?
Any comments or suggestions?

------=_NextPart_000_0015_01CD1A3B.D1BCB3D0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19222">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>Hi Rick,</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>&nbsp;&nbsp;&nbsp; Read this and I think you get
the idea.</FONT></DIV>
<DIV><FONT size=2 face=Arial>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Bruce</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>MSDN Blogs<BR>&nbsp;&gt;<BR>jfo's
coding<BR>&nbsp;&gt;<BR>Starting an application without showing a
form<BR>Starting an application without showing a
form<BR>4232/ProfileUrlRedirect.ashx<BR>jfoscoding<BR>24 Aug 2005 10:23
AM<BR>3<BR>There were a lot of good comments/questions about keeping your UI
responsive, if<BR>you're interested in threading/application contexts
etc,<BR>it's worth a peek<BR>.<BR>I thought I'd rehash something today I've
already talked about, but it is buried<BR>in my<BR>how to build notify icon
(system tray) applications article<BR>, and I think it's worthy of it's own
coverage here: how to run an application without<BR>showing a form<BR>Dissecting
Application.Run<BR>If you have created a Windows Forms application, you may have
happened across this<BR>line in Main:<BR>Application.Run(new
Form1());<BR>Magically, after calling this, the Form appears and events start
firing left and<BR>right.&nbsp; Here’s what is actually happening, not quite so
magically:<BR>//Taking a microscope to Application.Run –<BR>//create the form,
and call initialize component<BR>Form1 form1 = new Form1();<BR>// create an
application context<BR>ApplicationContext applicationContext = new
ApplicationContext();<BR>// Set applicationContext.MainForm so that<BR>// when
form1 closes, exit the application context<BR>applicationContext.MainForm =
form1;<BR>// Call Application.Run which will<BR>//&nbsp; -&nbsp; call
applicationContext.MainForm.Show()<BR>//&nbsp; -&nbsp; begin processing
events<BR>Application.Run(applicationContext);<BR>From this code, we can intuit
that the ApplicationContext defines when the Application<BR>should exit.&nbsp;
In fact the point of all the overloads to Application.Run is to help<BR>the
Application know when to quit.<BR>Running an application without showing a
form<BR>There are really two options here:<BR>Instead of calling Application.Run
with an argument, call Application.Run() to start<BR>processing messages with NO
arguments, then Application.Exit() when finished.&nbsp; This<BR>is not very
elegant as a missed call to Application.Exit means your application will<BR>keep
running even though there is no UI present.<BR>A much cleaner solution is to
inherit from the application context class and redefine<BR>when you think the
application should quit.&nbsp; The second solution is<BR>covered in depth with
sample here<BR>.<BR>Windows Forms<BR>Share on Facebook<BR>Share on
Twitter<BR>Share on Digg<BR>Share on
del.icio.us<BR>More<BR>Comments<BR>Loading...<BR>© 2012 Microsoft
Corporation.<BR>Terms of Use<BR>Trademarks<BR>Privacy Statement<BR>Report
Abuse<BR>5.6.402.223<BR></DIV></FONT>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=ofbgmail@mi.rr.com href="mailto:ofbgmail@mi.rr.com">RicksPlace</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=gw-scripting@gwmicro.com
href="mailto:gw-scripting@gwmicro.com">gw-scripting@gwmicro.com</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Saturday, April 14, 2012 9:22
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> .net Script Run() VS run(
ApplicationContext ) question</DIV>
<DIV><FONT size=2 face=Arial></FONT><BR></DIV>
<DIV><FONT size=2 face=Arial>Hi Aaron et al.</FONT></DIV>
<DIV><FONT size=2 face=Arial>Is there any advantage of starting a Vb.net
Script using Run( ApplicationContext) versus Run() method?</FONT></DIV>
<DIV><FONT size=2 face=Arial>I have tested them and They both work but I am
wondering about if either would be more robust when taking the fact that
WindowEyes, a ThirdParty Application like VWD and the vb.net script&nbsp;are
running at the same time.</FONT></DIV>
<DIV><FONT size=2 face=Arial>I have not found any articles yet on if running
in a new ApplicationContext class would help or hinder cross messaging, thread
priorities and, or, all that other Systems Programmer heavy weight
stuff.</FONT></DIV>
<DIV><FONT size=2 face=Arial>As far as I can tell it just specifies another
class to use in place of a form and watches for exiting of that class in this
case.</FONT></DIV>
<DIV><FONT size=2 face=Arial>Does that sound right?</FONT></DIV>
<DIV><FONT size=2 face=Arial>Any comments or suggestions?</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0015_01CD1A3B.D1BCB3D0--