Click here to Skip to main content
15,877,675 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Required msvcrt.pdb 7.0.2600.5512 Pin
John Schroedl4-Feb-11 5:19
professionalJohn Schroedl4-Feb-11 5:19 
AnswerRe: Required msvcrt.pdb 7.0.2600.5512 Pin
Hans Dietrich4-Feb-11 9:30
mentorHans Dietrich4-Feb-11 9:30 
QuestionCLI and Visual Studio 2008: IntelliSense Does not work Pin
Joschwenk6663-Feb-11 5:07
Joschwenk6663-Feb-11 5:07 
AnswerRe: CLI and Visual Studio 2008: IntelliSense Does not work Pin
John Schroedl3-Feb-11 8:45
professionalJohn Schroedl3-Feb-11 8:45 
QuestionHow to cancel console application? Pin
piul31-Jan-11 5:41
piul31-Jan-11 5:41 
AnswerRe: How to cancel console application? Pin
Luc Pattyn31-Jan-11 6:00
sitebuilderLuc Pattyn31-Jan-11 6:00 
GeneralRe: How to cancel console application? Pin
piul31-Jan-11 21:11
piul31-Jan-11 21:11 
AnswerRe: How to cancel console application? Pin
Luc Pattyn1-Feb-11 3:04
sitebuilderLuc Pattyn1-Feb-11 3:04 
piul wrote:
proc->WaitForExit();


this is a blocking call: the method waits, i.e. does not return, until the target process has exited. So if all the code shown is running on the main thread (say is part of an event handler, maybe a button click handler), then the main thread will sit there waiting , rather than handling all your Windows events (such as you clicking on the cancel button).

There are a couple of ways to solve your problem, the one I prefer is using an extra thread, probably a BackgroundWorker. Its DoWork handler would contain
proc->BeginOutputReadLine();//Start reading the output
proc->WaitForExit();

or even a synchronous loop to read the output, no need to use asynchronous when you already have a dedicated thread.

BTW: you can't directly touch GUI Controls from inside DoWork, so you should enable the cancel button before you launch the BGW, and disable it inside the RunWorkerCompleted handler.

One alternative would be to use a timer (a System.Windows.Forms.Timer at best), that ticks say every 300 msec. Its Tick handler could check (no wait!) whether the process has exited, and if it has, disable the cancel button and stop itself.

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

QuestionCString question Pin
ptr_Electron27-Jan-11 18:07
ptr_Electron27-Jan-11 18:07 
AnswerRe: CString question Pin
Richard MacCutchan27-Jan-11 23:04
mveRichard MacCutchan27-Jan-11 23:04 
AnswerRe: CString question Pin
jschell28-Jan-11 8:58
jschell28-Jan-11 8:58 
QuestionI am working on Windbg to analyse [modified] Pin
ptr_Electron24-Jan-11 23:32
ptr_Electron24-Jan-11 23:32 
AnswerRe: I am working on Windbg to analyse Pin
Richard MacCutchan25-Jan-11 3:05
mveRichard MacCutchan25-Jan-11 3:05 
QuestionHow to display an image on a activex webpage Pin
simon alec smith23-Jan-11 1:42
simon alec smith23-Jan-11 1:42 
AnswerRe: How to display an image on a activex webpage Pin
N a v a n e e t h24-Jan-11 6:09
N a v a n e e t h24-Jan-11 6:09 
QuestionGPS Support Pin
Ger Hayden13-Jan-11 22:10
Ger Hayden13-Jan-11 22:10 
AnswerRe: GPS Support Pin
jschell14-Jan-11 10:15
jschell14-Jan-11 10:15 
QuestionShow form minimized. Pin
TheBerk13-Jan-11 9:17
TheBerk13-Jan-11 9:17 
AnswerRe: Show form minimized. Pin
Richard MacCutchan13-Jan-11 10:41
mveRichard MacCutchan13-Jan-11 10:41 
QuestionGeneric Cyclic List Default Property [modified] Pin
Jason Titcomb6-Jan-11 0:59
Jason Titcomb6-Jan-11 0:59 
AnswerRe: Generic Cyclic List Default Property Pin
N a v a n e e t h10-Jan-11 1:14
N a v a n e e t h10-Jan-11 1:14 
Answercross-post alert Pin
Luc Pattyn6-Jan-11 2:11
sitebuilderLuc Pattyn6-Jan-11 2:11 
QuestionNeed to pass private member of a Class as a argument to function of another class Pin
ptr_Electron4-Jan-11 21:36
ptr_Electron4-Jan-11 21:36 
AnswerRe: Need to pass private member of a Class as a argument to function of another class Pin
Ger Hayden4-Jan-11 22:58
Ger Hayden4-Jan-11 22:58 
AnswerRe: Need to pass private member of a Class as a argument to function of another class Pin
Richard MacCutchan5-Jan-11 0:46
mveRichard MacCutchan5-Jan-11 0:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.