473,729 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using C# to launch apps

I am using a C# winform to launch some apps for our students. Basically the
user hits a button the form hides and the app is launched. When the app
exits, the form is unhidden. I have a question on two things. From what I
understand since I am starting the program from the Process.Start it is on a
separate thread and this is really not a problem. Secondly what is the best
way to work this form. Do I dispose of the form when I start the app or do I
hide it? The idea here is to keep student working on just what the buttons
allow.
Nov 17 '05 #1
7 2740
Christopher,

I think a good idea here would be to launch the Process from a separate
thread. You can then wait until the process is done on that thread.

Before you launch the process on another thread, from the UI thread, you
would hide the form. A good thing to do would be to have a NotifyIcon in
the tray.

In the thread waiting on the process, when the process completes, you
would call Invoke on the Form, passing a delegate to call the Show method
(or some other method indicating to proceed to the next step). Then, you
can continue from there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:28******** *************** ***********@mic rosoft.com...
I am using a C# winform to launch some apps for our students. Basically the
user hits a button the form hides and the app is launched. When the app
exits, the form is unhidden. I have a question on two things. From what I
understand since I am starting the program from the Process.Start it is on
a
separate thread and this is really not a problem. Secondly what is the
best
way to work this form. Do I dispose of the form when I start the app or do
I
hide it? The idea here is to keep student working on just what the buttons
allow.

Nov 17 '05 #2
Christopher,

It sounds like your application is like a "DashBoard" form where students
have the ability to run applications by clicking buttons on the dashboard
form. My suggestion is to hide your "DashBoard" form when the user clicks
the button that runs the application. When the user quits the application,
then you can show your "DashBoard" form again.

You say you are using the Process.Start method to run the application. This
works great. You can also subscribe to the Process "Exited" event. This gets
fired when the process exits (student closes the app) and show your
"DashBoard" form. =0}

Hope this makes sense.

Yosh.


"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:28******** *************** ***********@mic rosoft.com...
I am using a C# winform to launch some apps for our students. Basically the
user hits a button the form hides and the app is launched. When the app
exits, the form is unhidden. I have a question on two things. From what I
understand since I am starting the program from the Process.Start it is on
a
separate thread and this is really not a problem. Secondly what is the
best
way to work this form. Do I dispose of the form when I start the app or do
I
hide it? The idea here is to keep student working on just what the buttons
allow.

Nov 17 '05 #3
Do you have a good example of threading is this manner? I am very new to the
threading concept and have a hard time grasping it.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Christopher,

I think a good idea here would be to launch the Process from a separate
thread. You can then wait until the process is done on that thread.

Before you launch the process on another thread, from the UI thread, you
would hide the form. A good thing to do would be to have a NotifyIcon in
the tray.

In the thread waiting on the process, when the process completes, you
would call Invoke on the Form, passing a delegate to call the Show method
(or some other method indicating to proceed to the next step). Then, you
can continue from there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:28******** *************** ***********@mic rosoft.com...
I am using a C# winform to launch some apps for our students. Basically the
user hits a button the form hides and the app is launched. When the app
exits, the form is unhidden. I have a question on two things. From what I
understand since I am starting the program from the Process.Start it is on
a
separate thread and this is really not a problem. Secondly what is the
best
way to work this form. Do I dispose of the form when I start the app or do
I
hide it? The idea here is to keep student working on just what the buttons
allow.


Nov 17 '05 #4
Do you have a good article on events? I have limited knowledge of this.

"Yosh" wrote:
Christopher,

It sounds like your application is like a "DashBoard" form where students
have the ability to run applications by clicking buttons on the dashboard
form. My suggestion is to hide your "DashBoard" form when the user clicks
the button that runs the application. When the user quits the application,
then you can show your "DashBoard" form again.

You say you are using the Process.Start method to run the application. This
works great. You can also subscribe to the Process "Exited" event. This gets
fired when the process exits (student closes the app) and show your
"DashBoard" form. =0}

Hope this makes sense.

Yosh.


"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:28******** *************** ***********@mic rosoft.com...
I am using a C# winform to launch some apps for our students. Basically the
user hits a button the form hides and the app is launched. When the app
exits, the form is unhidden. I have a question on two things. From what I
understand since I am starting the program from the Process.Start it is on
a
separate thread and this is really not a problem. Secondly what is the
best
way to work this form. Do I dispose of the form when I start the app or do
I
hide it? The idea here is to keep student working on just what the buttons
allow.


Nov 17 '05 #5
Jonny Skeet has some very good examples:

http://www.yoda.arachsys.com/csharp/threads/

HTH

Ollie Riches
"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:2B******** *************** ***********@mic rosoft.com...
Do you have a good example of threading is this manner? I am very new to
the
threading concept and have a hard time grasping it.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Christopher,

I think a good idea here would be to launch the Process from a
separate
thread. You can then wait until the process is done on that thread.

Before you launch the process on another thread, from the UI thread,
you
would hide the form. A good thing to do would be to have a NotifyIcon in
the tray.

In the thread waiting on the process, when the process completes, you
would call Invoke on the Form, passing a delegate to call the Show method
(or some other method indicating to proceed to the next step). Then, you
can continue from there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:28******** *************** ***********@mic rosoft.com...
>I am using a C# winform to launch some apps for our students. Basically
>the
> user hits a button the form hides and the app is launched. When the app
> exits, the form is unhidden. I have a question on two things. From what
> I
> understand since I am starting the program from the Process.Start it is
> on
> a
> separate thread and this is really not a problem. Secondly what is the
> best
> way to work this form. Do I dispose of the form when I start the app or
> do
> I
> hide it? The idea here is to keep student working on just what the
> buttons
> allow.


Nov 17 '05 #6

Here's the MSDN events tutorial:

http://msdn.microsoft.com/library/de...tsTutorial.asp

And here's the MSDN C# Threading tutorial:

http://msdn.microsoft.com/library/de...ngTutorial.asp

If you follow Nicholas's suggestion of spinning off a worker thread here's
some code that can help with launching the process. This code configures how
the launched process's window should appear {for my needs I specifically
wanted shell execution and I wanted the launched process's window hidden} and
then it waits for the process to complete.

Do NOT use this code from the GUI thread - it's never good to block a GUI
thread - this code is for a worker thread. Also note the "using" clause, it
is important to dispose of the process instance after the process finishes
because the process instance keeps an open handle on the underlying OS until
it is explicitly disposed:

private void Execute(string exeName, string args)
{
using (process = new Process())
{
process.StartIn fo = new ProcessStartInf o(exeName, args);
process.StartIn fo.WorkingDirec tory = Path.GetDirecto ryName(exeName) ;
process.StartIn fo.ErrorDialog = false;
process.StartIn fo.UseShellExec ute = true;
process.StartIn fo.CreateNoWind ow = true;
process.StartIn fo.WindowStyle = ProcessWindowSt yle.Hidden;
process.Start() ;
process.WaitFor Exit();
}
}


"Christophe r C" wrote:
Do you have a good example of threading is this manner? I am very new to the
threading concept and have a hard time grasping it.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Christopher,

I think a good idea here would be to launch the Process from a separate
thread. You can then wait until the process is done on that thread.

Before you launch the process on another thread, from the UI thread, you
would hide the form. A good thing to do would be to have a NotifyIcon in
the tray.

In the thread waiting on the process, when the process completes, you
would call Invoke on the Form, passing a delegate to call the Show method
(or some other method indicating to proceed to the next step). Then, you
can continue from there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:28******** *************** ***********@mic rosoft.com...
I am using a C# winform to launch some apps for our students. Basically the
user hits a button the form hides and the app is launched. When the app
exits, the form is unhidden. I have a question on two things. From what I
understand since I am starting the program from the Process.Start it is on
a
separate thread and this is really not a problem. Secondly what is the
best
way to work this form. Do I dispose of the form when I start the app or do
I
hide it? The idea here is to keep student working on just what the buttons
allow.


Nov 17 '05 #7
I am looking at doing a Async call for the new process thread. Is there any
reason this would be a bad idea or am I on the right track?

"Richard" wrote:

Here's the MSDN events tutorial:

http://msdn.microsoft.com/library/de...tsTutorial.asp

And here's the MSDN C# Threading tutorial:

http://msdn.microsoft.com/library/de...ngTutorial.asp

If you follow Nicholas's suggestion of spinning off a worker thread here's
some code that can help with launching the process. This code configures how
the launched process's window should appear {for my needs I specifically
wanted shell execution and I wanted the launched process's window hidden} and
then it waits for the process to complete.

Do NOT use this code from the GUI thread - it's never good to block a GUI
thread - this code is for a worker thread. Also note the "using" clause, it
is important to dispose of the process instance after the process finishes
because the process instance keeps an open handle on the underlying OS until
it is explicitly disposed:

private void Execute(string exeName, string args)
{
using (process = new Process())
{
process.StartIn fo = new ProcessStartInf o(exeName, args);
process.StartIn fo.WorkingDirec tory = Path.GetDirecto ryName(exeName) ;
process.StartIn fo.ErrorDialog = false;
process.StartIn fo.UseShellExec ute = true;
process.StartIn fo.CreateNoWind ow = true;
process.StartIn fo.WindowStyle = ProcessWindowSt yle.Hidden;
process.Start() ;
process.WaitFor Exit();
}
}


"Christophe r C" wrote:
Do you have a good example of threading is this manner? I am very new to the
threading concept and have a hard time grasping it.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Christopher,

I think a good idea here would be to launch the Process from a separate
thread. You can then wait until the process is done on that thread.

Before you launch the process on another thread, from the UI thread, you
would hide the form. A good thing to do would be to have a NotifyIcon in
the tray.

In the thread waiting on the process, when the process completes, you
would call Invoke on the Form, passing a delegate to call the Show method
(or some other method indicating to proceed to the next step). Then, you
can continue from there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christophe r C" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:28******** *************** ***********@mic rosoft.com...
>I am using a C# winform to launch some apps for our students. Basically the
> user hits a button the form hides and the app is launched. When the app
> exits, the form is unhidden. I have a question on two things. From what I
> understand since I am starting the program from the Process.Start it is on
> a
> separate thread and this is really not a problem. Secondly what is the
> best
> way to work this form. Do I dispose of the form when I start the app or do
> I
> hide it? The idea here is to keep student working on just what the buttons
> allow.

Nov 17 '05 #8

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

Similar topics

9
6961
by: none | last post by:
Hello all, I wrote a shell program a few years ago in VB6 that needs to be modified. The problem I have is this: The SysAdmin uses this shell in place of Explorer, so there is no taskbar. When his users run PC Anywhere from the shell, and minimize it, it minimizes to the system tray. With no task bar, there is no system tray, so there is no way to restore the PC Anywhere window. The shell starts PC Anywhere using ShellExecute. I...
0
1186
by: akantrowitz | last post by:
I have a suite of winforms applications. In addition i would like a model where i can easily deploy new apps. I would like to build some type of launch pad application where i can dynamically display available apps for the users and allow them to launch the various apps from this central launching tool. thanks, Adam
2
1743
by: Howard Kaikow | last post by:
MSFT KB article 302896 includes a step by step example demonstrating how to build an Office COM in VB .NET, Yesterday, I implemented the example and it works correctly when starting each of the following Office 2003 apps from the quick launch bar: Access, Excel, Outlook, Powerpoint and Word. I used VB.NET 2003. Today, I tried to open an extant Word document. I tried two docs, one had already existed, the other was just created anew on...
1
953
by: teejayem | last post by:
Hi, I am new to using API's and am wondering if there are any good tutorials out there that explain how to use api's to control/change external applications in vb.net. Also if someone could help and explain to me how to do the following I would be extremely greatful. I have a button on my main form and I would like it to launch Remote Desktop and pre-type a computer name in the Remote Desktop Computer
4
4295
by: dotnetbeginner | last post by:
ASP .net -- VB .net -- IIS 5.1 --.NET 2.0 I want to perform excel automation on the server side and I wrote an asp .net page with the langauge vb .net. The goal of this program was to open an excel file on my local drive (localhost), manipulate the data and save as another file. It works perfectly from Visual Web Developer 2005. When I run from direct IE using the URL http://localhost/<app>/<startpage>.aspx, it displays the page properly,...
3
3575
by: =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post by:
I'm building a test web application that, when run, will launch calc.exe on my computer. It seems to work as it appears in Windows Task Manager; however, the process doesn't actually pop up because it runs as ASPNET rather than the user I want. When having to run ASP.NET as another user (e.g. when doing AD queries), I was able to use IIS Windows Authentication and impersonation. These are still enabled, but they don't seem to be helping....
1
1655
BezerkRogue
by: BezerkRogue | last post by:
I have created a VB Script to synchronize software versions and then launch an application on the system it is run against. The script runs and generates no errors but will not launch the second application. The application name is dynamic and is selected from table. WScript.Echo verifies that it is calling the correct application and the path statement is correct. Also the application does reside where I am calling it from. The code...
8
6610
by: r0g | last post by:
Hi There, I'm trying to migrate a locally hosted page from windows to a private Ubuntu development server and one of the key bits of functionality (which used to work fine in Windows) was the ability for the page to start a file browser via PHP's exec() function. I can't get this working under Ubuntu though e.g. <?php exec('nautilus /var/www'); ?>
6
2627
by: tempnode | last post by:
I have a problem that I can't seem to solve: I need to write a C++ app that will run off of a floppy. Basically, I will boot into DOS (from a floppy), and run my executable from the floppy. The executable will crunch some data and then launch another application.
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
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 we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.