Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / November 2004

Tip: Looking for answers? Try searching our database.

How to let visual.net process messages while executing an external

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jean-Sebastien Pelletier - 11 Sep 2004 21:57 GMT
Hi,

I'm writing an addin and I've hooked myself to the build event to be able to
execute an external program at the start of the build. In itself it works
very well. Part of the code is below.

My problem is that I'd like to be able to cancel the build while this
external process is running similar to any other build cancellation.. Which
means that I want visual.net to still process its events. To be able to do
that I've hooked myself to the BeforeCommand event of the Build.Cancel
command but as long as the external process runs the cancellation event
doesn't occurs(as the event is not processed until the end of the process)

Does anybody know what I would have to add in my loop to be able to let
visual.net handle all it's events ?

Thanks
J-S

private void OnBuildBegin(vsBuildScope scope, vsBuildAction action)
{
if (action == vsBuildAction.vsBuildActionBuild ||
 action == vsBuildAction.vsBuildActionClean ||
 action == vsBuildAction.vsBuildActionRebuildAll)
{
 // skipped unimportant stuff...

 // Execute
 System.Diagnostics.Process p = new System.Diagnostics.Process();
 p.StartInfo.FileName = m_InstallPath + "parser.exe";
 p.StartInfo.Arguments = Arguments;
 p.StartInfo.CreateNoWindow = true;
 p.StartInfo.UseShellExecute = false;
 p.StartInfo.RedirectStandardOutput = true;
 p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
 p.Start();

 string line;
 while(!p.HasExited)
 {
  line = p.StandardOutput.ReadLine();
  DisplayOutput(line + "\n");
 }
 // Insure that we don't miss the remaining output.
 line = p.StandardOutput.ReadToEnd();
 DisplayOutput(line + "\n");
 p.WaitForExit();
}
}
Jean-Sebastien Pelletier - 12 Sep 2004 01:27 GMT
BTW, I can't execute this external process in an external thread and from
there process the output of the program and write it to the output window to
let visual.net process the events because the external process MUST finish
completely before the build can continue...
Tim Farley - 30 Sep 2004 20:59 GMT
Have you tried calling Application.DoEvents() inside your loop?  That seems
to work for me but I admit I haven't tried to receive a VS.NET event during
that.

--Tim Farley
Jean-Sebastien Pelletier - 09 Oct 2004 19:03 GMT
Humm, I don't know where you've seen that method, but I can't find it in any
class.
On what exact type of object are you calling this ?

Thanks
J-S
Tim Farley - 17 Nov 2004 19:34 GMT
Tim Farley wrote:
> Application.DoEvents()

> Humm, I don't know where you've seen that method, but I can't find it in any
> class.  On what exact type of object are you calling this ?

It is a standard .NET Framework method.  If you are writing your add-in in
non-managed code, you don't have easy access to it.  If you are writing in
managed code, you'll need to reference the System.Windows.Forms namespace to
see it.

--Tim Farley

--Tim Farley

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.