Click here to Skip to main content
15,917,808 members
Home / Discussions / C#
   

C#

 
AnswerRe: dynamic retrieval of available SQL Servers Pin
Ed.Poore20-Jan-07 9:43
Ed.Poore20-Jan-07 9:43 
GeneralRe: dynamic retrieval of available SQL Servers Pin
tgrt20-Jan-07 12:48
tgrt20-Jan-07 12:48 
GeneralRe: dynamic retrieval of available SQL Servers Pin
Ed.Poore20-Jan-07 12:58
Ed.Poore20-Jan-07 12:58 
Questionsetting the startup form in Windows Application Pin
Rocky#20-Jan-07 5:31
Rocky#20-Jan-07 5:31 
AnswerRe: setting the startup form in Windows Application Pin
Luc Pattyn20-Jan-07 6:50
sitebuilderLuc Pattyn20-Jan-07 6:50 
GeneralRe: setting the startup form in Windows Application Pin
Rocky#21-Jan-07 19:30
Rocky#21-Jan-07 19:30 
QuestionThread Problems Pin
Eddymvp20-Jan-07 4:59
Eddymvp20-Jan-07 4:59 
AnswerRe: Thread Problems Pin
Marc Clifton20-Jan-07 5:06
mvaMarc Clifton20-Jan-07 5:06 
You don't want the application controlling the thread sleeping, you want the thread itself sleeping and determining when to exit.

void MakeThread()
{
  Thread t1 = new Thread( new ThreadStart(MyMethod));
  t1.IsBackground=true;
  t1.Start();
}

void MyMethod()
{
  while (++stop != 1000)
  {
    // Do stuff
    Thread.Sleep(5000);
  }
}


Note setting the IsBackground to true, so if your application exits, the thread will terminate too. Otherwise you can have threads running even when your application has quit.

However, this isn't really what threads are intended for. Sounds more like what you want is a timer that fires every 5 seconds.

Marc






Thyme In The Country

People are just notoriously impossible. --DavidCrow
There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith


AnswerRe: Thread Problems Pin
Guffa20-Jan-07 5:12
Guffa20-Jan-07 5:12 
AnswerRe: Thread Problems Pin
Luc Pattyn20-Jan-07 5:22
sitebuilderLuc Pattyn20-Jan-07 5:22 
GeneralRe: Thread Problems Pin
Eddymvp20-Jan-07 5:27
Eddymvp20-Jan-07 5:27 
GeneralRe: Thread Problems Pin
Luc Pattyn20-Jan-07 5:36
sitebuilderLuc Pattyn20-Jan-07 5:36 
GeneralRe: Thread Problems Pin
Eddymvp20-Jan-07 5:47
Eddymvp20-Jan-07 5:47 
Questionfiletypes Pin
dsl/fahk20-Jan-07 3:53
dsl/fahk20-Jan-07 3:53 
AnswerRe: filetypes Pin
Luc Pattyn20-Jan-07 4:01
sitebuilderLuc Pattyn20-Jan-07 4:01 
AnswerRe: filetypes Pin
David Domingues22-Jan-07 5:02
David Domingues22-Jan-07 5:02 
QuestionRead text file after uploaded Pin
ALAQUNAIBI20-Jan-07 2:11
ALAQUNAIBI20-Jan-07 2:11 
AnswerRe: Read text file after uploaded Pin
Christian Graus20-Jan-07 10:22
protectorChristian Graus20-Jan-07 10:22 
GeneralRe: Read text file after uploaded Pin
ALAQUNAIBI20-Jan-07 19:52
ALAQUNAIBI20-Jan-07 19:52 
GeneralRe: Read text file after uploaded Pin
Christian Graus20-Jan-07 21:43
protectorChristian Graus20-Jan-07 21:43 
QuestionRead-Write thread synchronization Pin
Den2Fly20-Jan-07 1:11
Den2Fly20-Jan-07 1:11 
AnswerRe: Read-Write thread synchronization Pin
Luc Pattyn20-Jan-07 1:38
sitebuilderLuc Pattyn20-Jan-07 1:38 
GeneralRe: Read-Write thread synchronization Pin
Den2Fly20-Jan-07 3:54
Den2Fly20-Jan-07 3:54 
GeneralRe: Read-Write thread synchronization Pin
Luc Pattyn20-Jan-07 4:00
sitebuilderLuc Pattyn20-Jan-07 4:00 
GeneralRe: Read-Write thread synchronization Pin
Den2Fly20-Jan-07 4:37
Den2Fly20-Jan-07 4:37 

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.