Home > Net >  Open the while (true) threads, interface card dead, increased memory
Open the while (true) threads, interface card dead, increased memory

Time:10-03

Controls how to use the while (true) cycle threads, or there are other ways

CodePudding user response:

Open the thread, as a result, entrusted to the UI thread

CodePudding user response:

What other requirements allowing you to use the infinite loop

CodePudding user response:

refer to the original poster weixin_39516696 response:
control that how to use the while (true) cycle threads, or there are other ways

While (true) your sure??????

CodePudding user response:

Pay attention to out of memory and thread

CodePudding user response:

While (true) is the use of taboo,,,,

CodePudding user response:

This is an infinite loop

CodePudding user response:

So your code is

 
While (true)
{
Var t=new thread ()...
T.s tart ();
}


The code you give you the universe a newbest computer can run...

Why don't you tell me what you want to achieve from the requirements?

I think may be just a timer can solve the problem of... Have to get so complicated..

CodePudding user response:

While true

You can use the

The point is, when you jump out of the loop

You always get down, get your computer memory 100%

Direct crash, there are a few mean
?

CodePudding user response:

Microsoft has this command, it can be used to estimate you are waiting for the change of the value of a global variable to jump out of the loop, suggest you add a thread sleep (1), even sleep 1 millisecond, are so different and not sleep,

When such as debugging movement control CARDS, need axis movement to a certain point, at that time while true command is delightfully simple, brush the TIMER is too much trouble, because it is in the debugging process, there is no UI card BuKa problem,

CodePudding user response:

You directly in the thread pool is ok,
Have a task, do it to the thread pool,
As a rookie,
Don't have to struggle to give up strategy first, as long as concerned about the maximum number of threads, and logging the exception is good,

CodePudding user response:

Nothing had power to restart

CodePudding user response:

Many source will be used in the while (true) or infinite for loop, especially in the in the process of acquiring a lock could be infinite loop to acquiring a lock, the main thing is that you should have critical condition or exit condition, at the time of programming can sleep or wait a minute

CodePudding user response:

Beginners and people who do not understand the various principles of program run is not recommended
 while (true) 
{
//your code
}

And

 goto # lable 


The reason is very simple, because although convenient but you need to use more time and energy to consider how to use more safe and effective,
According to communicate with your upstairs to see you, you are not suitable for these,

CodePudding user response:

You can use the while (true) to create a thread, such as in the socket communication, the server will need to use the while (true) to continuously monitor the client's request, the newly built their communication thread, but you have to think of when we need to create a thread, when a thread will release again, have been a new thread if meaningless, not only the page jammed, the computer will crash, your question is too general, you put the requirements, or to the code, directly ask so who knows what you said is what

CodePudding user response:

Open the background thread or the timer

CodePudding user response:

You can use the timer

CodePudding user response:

reference 1st floor HyoJung response:
open thread, the entrusted to the UI thread

Thank you very much, the problem to solve, to run the stability!

CodePudding user response:

refer to the eighth floor tangyanzhi1111 response:
while true

You can use the

The point is, when you jump out of the loop

You always get down, get your computer memory 100%

Direct crash, there are a few mean
?

I in order to solve problems, you don't know the specific question, please don't say rude words

CodePudding user response:

references 9/f, lover and response:
Microsoft have this command, it can be used, estimates that you are waiting for the change of the value of a global variable to jump out of the loop, suggest you add a thread sleep (1), even sleep 1 millisecond, are so different and not sleep,

When such as debugging movement control CARDS, need axis movement to a certain point, at that time while true command is delightfully simple, brush the TIMER is too much trouble, because it is in the debugging process, there is no UI card BuKa problem,

Ok, thank you very much, the problem has been solved

CodePudding user response:

Agree on the first floor, with the threads, while true in the thread

CodePudding user response:

Can use a for loop, I wrote the program for many years, to be honest while not commonly used, use a for loop
For
{
If (true) break;
}
  •  Tags:  
  • C#
  • Related