Click here to Skip to main content
15,916,189 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: How to get my Word templates and AutoTexts with Interop? [modified] Pin
musefan16-Feb-11 4:05
musefan16-Feb-11 4:05 
GeneralRe: How to get my Word templates and AutoTexts with Interop? [modified] Pin
musefan16-Feb-11 4:13
musefan16-Feb-11 4:13 
GeneralRe: How to get my Word templates and AutoTexts with Interop? Pin
Bernhard Hiller16-Feb-11 20:00
Bernhard Hiller16-Feb-11 20:00 
AnswerRe: How to get my Word templates and AutoTexts with Interop? Pin
Bernhard Hiller16-Feb-11 20:41
Bernhard Hiller16-Feb-11 20:41 
QuestionHow to resolve sgen.exe error Pin
meeram39515-Feb-11 21:37
meeram39515-Feb-11 21:37 
AnswerRe: How to resolve sgen.exe error Pin
Richard MacCutchan15-Feb-11 23:02
mveRichard MacCutchan15-Feb-11 23:02 
AnswerRe: How to resolve sgen.exe error Pin
Yusuf16-Feb-11 3:21
Yusuf16-Feb-11 3:21 
QuestionProcess::HasExited always true Pin
piul15-Feb-11 2:07
piul15-Feb-11 2:07 
AnswerRe: Process::HasExited always true Pin
Luc Pattyn15-Feb-11 3:10
sitebuilderLuc Pattyn15-Feb-11 3:10 
GeneralRe: Process::HasExited always true Pin
piul15-Feb-11 3:20
piul15-Feb-11 3:20 
GeneralRe: Process::HasExited always true Pin
Ravi Sant15-Feb-11 3:42
Ravi Sant15-Feb-11 3:42 
AnswerRe: Process::HasExited always true Pin
RobCroll15-Feb-11 4:20
RobCroll15-Feb-11 4:20 
AnswerRe: Process::HasExited always true Pin
Eddy Vluggen16-Feb-11 2:07
professionalEddy Vluggen16-Feb-11 2:07 
QuestionAccessing control from a different thread Pin
piul14-Feb-11 23:18
piul14-Feb-11 23:18 
AnswerRe: Accessing control from a different thread Pin
piul14-Feb-11 23:41
piul14-Feb-11 23:41 
AnswerRe: Accessing control from a different thread Pin
Simon_Whale14-Feb-11 23:59
Simon_Whale14-Feb-11 23:59 
AnswerRe: Accessing control from a different thread Pin
Luc Pattyn15-Feb-11 3:14
sitebuilderLuc Pattyn15-Feb-11 3:14 
QuestionExternal process stops everything else Pin
piul14-Feb-11 0:31
piul14-Feb-11 0:31 
AnswerRe: External process stops everything else Pin
Luc Pattyn14-Feb-11 1:06
sitebuilderLuc Pattyn14-Feb-11 1:06 
GeneralRe: External process stops everything else Pin
piul14-Feb-11 2:25
piul14-Feb-11 2:25 
GeneralRe: External process stops everything else Pin
Luc Pattyn14-Feb-11 2:37
sitebuilderLuc Pattyn14-Feb-11 2:37 
OK, that is quite wrong for several reasons:

1.
the while loop has no blocking calls, so it will spin at full speed, consuming all cycles of one (perhaps the only) core. If you must have a polling loop like that, at least slow it down by inserting say Thread.Sleep(100);
However it is in general better to avoid a polling loop.

2.
It is not OK to halt the main thread like that, as the whole GUI will freeze. If e.g. another window pops up on top of your app, and then goes away again, your app won't repaint itself.

The correct approach would be:
- to have a separate thread (I suggest a BackgroundWorker) which launches the process, captures its output, and waits for its termination;
- to launch this thread from your button click handler (possibly also disabling said button, turning the cursor into a wait cursor, etc);
- to have a delegate dealing with intermediate results (maybe showing them in a ListBox);
- to have another delegate dealing with the termination of the process (restoring the GUI back to normal).

BTW: said thread would not need a polling loop on superMinerProcess->HasExited, as it could use superMinerProcess->WaitForExit()

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.

GeneralRe: External process stops everything else Pin
piul14-Feb-11 4:34
piul14-Feb-11 4:34 
AnswerRe: External process stops everything else Pin
Luc Pattyn14-Feb-11 4:43
sitebuilderLuc Pattyn14-Feb-11 4:43 
GeneralRe: External process stops everything else Pin
piul14-Feb-11 5:08
piul14-Feb-11 5:08 
GeneralRe: External process stops everything else Pin
Luc Pattyn14-Feb-11 5:51
sitebuilderLuc Pattyn14-Feb-11 5:51 

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.