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.StartInfo = new ProcessStartInfo(exeName, args);
process.StartInfo.WorkingDirectory = Path.GetDirectoryName(exeName);
process.StartInfo.ErrorDialog = false;
process.StartInfo.UseShellExecute = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
}
}
"Christopher 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.com
"Christopher C" <Ch**********@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.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.