Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
AnswerRe: Renaming an Interop file Pin
Christian Graus26-Apr-07 11:50
protectorChristian Graus26-Apr-07 11:50 
GeneralRe: Renaming an Interop file Pin
lost in transition 27-Apr-07 6:27
lost in transition 27-Apr-07 6:27 
Questioncombobox in gridview Pin
Mohammed Elkholy26-Apr-07 10:11
Mohammed Elkholy26-Apr-07 10:11 
AnswerRe: combobox in gridview Pin
isamir26-Apr-07 11:31
isamir26-Apr-07 11:31 
AnswerRe: combobox in gridview Pin
Keshav V. Kamat26-Apr-07 18:48
Keshav V. Kamat26-Apr-07 18:48 
GeneralRe: combobox in gridview Pin
Nouman Bhatti26-Apr-07 21:11
Nouman Bhatti26-Apr-07 21:11 
Questionvisual studio 2005 Pin
salie0026-Apr-07 9:52
salie0026-Apr-07 9:52 
QuestionCan I Hard Kill a Thread? Pin
Jimmanuel26-Apr-07 9:42
Jimmanuel26-Apr-07 9:42 
My situation is this:

I'm writing an app that needs to execute a separate program (we'll call it aaa.exe) and monitor its output so that my app can display the status of aaa.exe to the user. To do this I've started aaa.exe using a Process and have redirected the STDOUT stream to a StreamReader so that I can monitor the status messages that it spits out and use that information to update a status variable. Basically, what I have to monitor the stream is this:
string line = "";
while (line = stdout.ReadLine()) != null)
{
    // do stuff 
}

and then I parse line to determine the status of the spawned application. To prevent this while loop from locking up my GUI I've moved this code to another thread, so that the status variable will continually be updated by one thread and the GUI can intermittently poll that variable from it's own thread and remain responsive to the user.

Under normal circumstances, this works well. The while loop continues until aaa.exe stops sending data to STDOUT and then the thread monitoring it exits happily and all is well. The problem arises when things don't go well in aaa.exe. It is possible under worst case scenario conditions (so this happens frequently while I'm testing) that the spawned application locks up. When this happens, my code freezes execution on the function call stdout.ReadLine(), and I now have a deadlocked thread. The most direct way to end the rogue thread is to hard kill the process for aaa.exe (using Process.Kill()), but my boss has just informed that this is not an acceptable solution as it causes horrendous side effects to the operating environment. Using Thread.Abort has no apparent effect, it seems to wait for the next instruction to finish before doing anything to the thread which means nothing if the thread is suspended in a function call. So my question is this: is there some other way to end the Thread without killing the instance of aaa.exe, or more generally, is there some way to kill a non-responsive Thread in my application without doing a hard kill on the application itself?
AnswerRe: Can I Hard Kill a Thread? Pin
Judah Gabriel Himango26-Apr-07 12:30
sponsorJudah Gabriel Himango26-Apr-07 12:30 
GeneralRe: Can I Hard Kill a Thread? Pin
Jimmanuel26-Apr-07 13:53
Jimmanuel26-Apr-07 13:53 
QuestionConsole.WriteLine - need help Pin
Slow Learner26-Apr-07 9:20
Slow Learner26-Apr-07 9:20 
AnswerRe: Console.WriteLine - need help Pin
netJP12L26-Apr-07 9:31
netJP12L26-Apr-07 9:31 
AnswerRe: Console.WriteLine - need help Pin
isamir26-Apr-07 11:40
isamir26-Apr-07 11:40 
AnswerRe: Console.WriteLine - need help Pin
Abdul Sami X26-Apr-07 21:28
Abdul Sami X26-Apr-07 21:28 
Questioncontrol on form Pin
netJP12L26-Apr-07 8:33
netJP12L26-Apr-07 8:33 
AnswerRe: control on form Pin
Arun.Immanuel26-Apr-07 14:28
Arun.Immanuel26-Apr-07 14:28 
QuestionMySQL Connection Pin
Gareth H26-Apr-07 7:37
Gareth H26-Apr-07 7:37 
AnswerRe: MySQL Connection Pin
Wayne Phipps26-Apr-07 8:33
Wayne Phipps26-Apr-07 8:33 
GeneralRe: MySQL Connection Pin
Wayne Phipps26-Apr-07 9:22
Wayne Phipps26-Apr-07 9:22 
GeneralRe: MySQL Connection Pin
Gareth H27-Apr-07 0:05
Gareth H27-Apr-07 0:05 
QuestionTextbox Error/Problem? Pin
Gareth H26-Apr-07 7:27
Gareth H26-Apr-07 7:27 
AnswerRe: Textbox Error/Problem? Pin
mnvkng7626-Apr-07 17:07
mnvkng7626-Apr-07 17:07 
GeneralRe: Textbox Error/Problem? Pin
Gareth H26-Apr-07 22:24
Gareth H26-Apr-07 22:24 
QuestionMysql Hash Password? Pin
Eddymvp26-Apr-07 6:55
Eddymvp26-Apr-07 6:55 
AnswerRe: Mysql Hash Password? Pin
Guffa26-Apr-07 11:14
Guffa26-Apr-07 11:14 

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.