Click here to Skip to main content
15,895,740 members
Home / Discussions / C#
   

C#

 
AnswerRe: RSA Private Key Security Pin
Ed.Poore7-Jun-06 10:37
Ed.Poore7-Jun-06 10:37 
GeneralRe: RSA Private Key Security Pin
Clonus8-Jun-06 2:59
Clonus8-Jun-06 2:59 
GeneralRe: RSA Private Key Security Pin
Clonus8-Jun-06 3:56
Clonus8-Jun-06 3:56 
GeneralRe: RSA Private Key Security Pin
Ed.Poore8-Jun-06 8:11
Ed.Poore8-Jun-06 8:11 
QuestionGetMembers and COM Pin
dcadenas7-Jun-06 9:00
dcadenas7-Jun-06 9:00 
QuestionUpdate progress bar from a separate project Pin
snorkie7-Jun-06 8:34
professionalsnorkie7-Jun-06 8:34 
AnswerRe: Update progress bar from a separate project Pin
Stefan Troschuetz7-Jun-06 10:01
Stefan Troschuetz7-Jun-06 10:01 
QuestionAborting / Killing Threads Pin
MrEyes7-Jun-06 8:08
MrEyes7-Jun-06 8:08 
Hello all, I seem to be having a small problem killing threads in a console application.

The symptoms of the problem is that the application never exits, and I can only assume that this is due to a threading issue.

I currently have the following (edited for simplicity) code:

int threadTimeout = 2000;

for (int loop=0; loop < syncServers.Length; loop++)
{
 this.syncServer = syncServers[loop];

 Thread syncThread = new Thread(new ThreadStart(DoSync));
 syncThread.Start();

 //sleep the main thread
 Thread.Sleep(threadTimeout);

 if (syncThread.IsAlive)
 {
   syncThread.Abort()
 }
}


private void DoSync()
{
  //stuff that requires threading
  DoTimeSync(this.syncServer)

}


Now lets say that syncServers has three items, the code cycles through each one waiting for the timeout. However when the last one completes the application just hangs, I would expect it to close (there is no further code after the end of the for loop)

EDIT : Just for clarity, the reason I am doing this is that I am using UDP to perform time synchronisation requests, unfortunatly the .NET 1.1 UDP listener doesnt support a timeout and if the sync server doesnt exisit the UDP listener sits and waits for ever.

EDIT 2 : I have also try using:

if (syncThread.ThreadState != ThreadState.Stopped)
{
 syncThread.Abort()
}

AnswerRe: Aborting / Killing Threads Pin
Ed.Poore7-Jun-06 10:45
Ed.Poore7-Jun-06 10:45 
QuestionMDI form child closing [modified] Pin
ak877-Jun-06 6:51
ak877-Jun-06 6:51 
AnswerRe: MDI form child closing [modified] Pin
Josh Smith7-Jun-06 9:16
Josh Smith7-Jun-06 9:16 
QuestionConstraints [modified] Pin
kjosh7-Jun-06 6:48
kjosh7-Jun-06 6:48 
AnswerRe: Constraints Pin
dreynglar8-Jun-06 7:05
dreynglar8-Jun-06 7:05 
QuestionC#/SQL Question Pin
leckey7-Jun-06 6:27
leckey7-Jun-06 6:27 
AnswerRe: C#/SQL Question Pin
NaNg152417-Jun-06 6:50
NaNg152417-Jun-06 6:50 
GeneralRe: C#/SQL Question Pin
Colin Angus Mackay7-Jun-06 8:13
Colin Angus Mackay7-Jun-06 8:13 
AnswerRe: C#/SQL Question Pin
Gerald Schwab7-Jun-06 6:53
Gerald Schwab7-Jun-06 6:53 
GeneralRe: C#/SQL Question Pin
Colin Angus Mackay7-Jun-06 8:14
Colin Angus Mackay7-Jun-06 8:14 
GeneralRe: C#/SQL Question Pin
Gerald Schwab9-Jun-06 7:07
Gerald Schwab9-Jun-06 7:07 
GeneralRe: C#/SQL Question Pin
Colin Angus Mackay9-Jun-06 11:20
Colin Angus Mackay9-Jun-06 11:20 
AnswerRe: C#/SQL Question Pin
malikjhangirahmed@hotmail.com7-Jun-06 7:21
malikjhangirahmed@hotmail.com7-Jun-06 7:21 
GeneralRe: C#/SQL Question Pin
Colin Angus Mackay7-Jun-06 8:14
Colin Angus Mackay7-Jun-06 8:14 
AnswerRe: C#/SQL Question Pin
Colin Angus Mackay7-Jun-06 8:11
Colin Angus Mackay7-Jun-06 8:11 
QuestionRe: C#/SQL Question Pin
leckey7-Jun-06 8:15
leckey7-Jun-06 8:15 
AnswerRe: C#/SQL Question Pin
Colin Angus Mackay7-Jun-06 8:29
Colin Angus Mackay7-Jun-06 8:29 

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.