|
while (true)
{
new Thread(() =>
{
}).Start();
} Am I doing this right?
|
|
|
|
|
I'd come after you for that. You're not the only one with a pitchfork - I collect them from villagers.
Real programmers use butterflies
|
|
|
|
|
Alright, how about I optimize that using the faster and lightweight TPL?
Lightweight threads from the threadpool, or, if possible, just time slice and save the overhead from starting up a new thread altogether!
while (true)
{
Task.Factory.StartNew(() => {
});
} All fixed
|
|
|
|
|
Unless you need to pass in a custom scheduler or something like that you really should use Task.Run()
While TaskFactory.StartNew() isn't obsolete or anything, the overload you're using has been supplanted by Task.Run()
I think I read that from Stephen Toub, but it could have been someone else at the Microsoft blogs.
Just sayin'
*hides*
Real programmers use butterflies
|
|
|
|
|
I actually always use Task.Start except for the very beginning when TPL was hot and happening.
It's just that I don't have a lot of need for it anymore and it's been a while since I last used it.
I had to Google and TaskFactory.StartNew was the first one that came up.
However, none of that matters with the while(true) still in place
|
|
|
|
|
i think you mean Task.Run()
But yeah,although if you really want to be obnoxious you do
while(true) {
new Thread(()=> { while(true); }).Start();
}
So it chokes the scheduler
Real programmers use butterflies
|
|
|
|
|
|
If you ever manage actual endless recursion on a Linear Bounded Automata (like a computer) you will have solved several undecidable computer science problems and opened up a huge can of worms to boot.
I'd pay for front row seats to that.
If however, you simply want a stack overflow exception, I can work with that too.
Real programmers use butterflies
|
|
|
|
|
Isn't that what functional languages do?
Well, not really, since they compile to while loops, but the effect is the same
|
|
|
|
|
Sander Rossel wrote: Can we put some endless recursion in there too? As long as it is not an endless discussion...
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
public void Discuss(bool myOpinion, bool otherOpinion)
{
if (myOpinion == otherOpinion)
{
myOpinion != myOpinion;
}
else
{
otherOpinion = myOpinion;
}
Discuss(myOpinion, otherOpinion);
}
|
|
|
|
|
Agreed, because this system shouldn't waste time before crashing.
|
|
|
|
|
I just want the crashing code to follow Microsoft guidelines and best practices.
Real programmers use butterflies
|
|
|
|
|
Don't tell me you have started to work for the WinUpdates team...
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Needs some recursion. Too understandable as-is. Maybe call this from within the instantiated threads. Yeah, that's it!
|
|
|
|
|
let's just skip right to Stack::Blow();
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
Computers need stress tested every once in a while!
|
|
|
|
|
Just tell your computer "we need to talk"
|
|
|
|
|
Yeah, I talked to him before. He's a slightly higher level of noob playing with devices he has little experience with. I saw the docs he's got and they're just a list of function headers with little explanation, written entirely in Chinese.
He was hell-bent on "creating an instance of the API for each reader". I told him he would have to create a class to talk to the readers himself since there isn't one in the library.
|
|
|
|
|
I admire his tenacity at least.
Punching outside your weight class isn't all bad, when you're learning stuff.
It's hard to justify when you're getting paid though.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: Punching outside your weight class isn't all bad
That's how you learn, for good and for bad
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
honey the codewitch wrote: And now I feel like a gave a child a loaded pistol
I don't see what the issue is. It sounds like a problem that will soon sort itself out.
|
|
|
|
|
|
Most excellent!
I may even have found my next SOTW
|
|
|
|
|
Great ..
BR
|
|
|
|