Click here to Skip to main content
15,888,113 members
Home / Discussions / C#
   

C#

 
QuestionWaiting for thread to exit? Pin
SledgeHammer018-Nov-14 17:07
SledgeHammer018-Nov-14 17:07 
GeneralRe: Waiting for thread to exit? Pin
PIEBALDconsult8-Nov-14 17:19
mvePIEBALDconsult8-Nov-14 17:19 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer018-Nov-14 17:24
SledgeHammer018-Nov-14 17:24 
GeneralRe: Waiting for thread to exit? Pin
PIEBALDconsult8-Nov-14 17:32
mvePIEBALDconsult8-Nov-14 17:32 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer018-Nov-14 17:39
SledgeHammer018-Nov-14 17:39 
GeneralRe: Waiting for thread to exit? Pin
Dave Kreskowiak8-Nov-14 18:59
mveDave Kreskowiak8-Nov-14 18:59 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer018-Nov-14 19:20
SledgeHammer018-Nov-14 19:20 
GeneralRe: Waiting for thread to exit? Pin
Dave Kreskowiak9-Nov-14 4:43
mveDave Kreskowiak9-Nov-14 4:43 
Very interesting. Well, I verified it. That's the most screwed up thing ever.

But, I hate to tell you this, but the one running under the debugger is lying to you. It's the one that's screwed up, not the one executing out of the debugger.

For some reason, the debugger is keeping the Task alive when it shouldn't be. Tasks are running out of the thread pool, which are all background threads. When your main thread exited, it took the Task with it, killing the threadCurrent.Join and never allowing it to get to b = true. That's why your worker thread stays alive.

I'd convert the Task to a foreground Thread instead.

[EDIT]
Oh, I almost forgot! You might want to post this on Connect[^] for a possible Visual Studio bug.
A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

GeneralRe: Waiting for thread to exit? Pin
Eddy Vluggen9-Nov-14 5:59
professionalEddy Vluggen9-Nov-14 5:59 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer019-Nov-14 7:31
SledgeHammer019-Nov-14 7:31 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer019-Nov-14 7:28
SledgeHammer019-Nov-14 7:28 
GeneralRe: Waiting for thread to exit? Pin
PIEBALDconsult9-Nov-14 5:59
mvePIEBALDconsult9-Nov-14 5:59 
GeneralRe: Waiting for thread to exit? Pin
Dave Kreskowiak9-Nov-14 7:08
mveDave Kreskowiak9-Nov-14 7:08 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer019-Nov-14 7:48
SledgeHammer019-Nov-14 7:48 
GeneralRe: Waiting for thread to exit? Pin
Dave Kreskowiak9-Nov-14 10:31
mveDave Kreskowiak9-Nov-14 10:31 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer019-Nov-14 11:18
SledgeHammer019-Nov-14 11:18 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer019-Nov-14 7:37
SledgeHammer019-Nov-14 7:37 
GeneralRe: Waiting for thread to exit? Pin
PIEBALDconsult9-Nov-14 7:54
mvePIEBALDconsult9-Nov-14 7:54 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer019-Nov-14 7:57
SledgeHammer019-Nov-14 7:57 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer019-Nov-14 8:00
SledgeHammer019-Nov-14 8:00 
GeneralRe: Waiting for thread to exit? Pin
PIEBALDconsult9-Nov-14 8:13
mvePIEBALDconsult9-Nov-14 8:13 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer019-Nov-14 8:49
SledgeHammer019-Nov-14 8:49 
GeneralRe: Waiting for thread to exit? Pin
PIEBALDconsult9-Nov-14 8:55
mvePIEBALDconsult9-Nov-14 8:55 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer019-Nov-14 9:17
SledgeHammer019-Nov-14 9:17 
GeneralRe: Waiting for thread to exit? Pin
Eddy Vluggen10-Nov-14 8:34
professionalEddy Vluggen10-Nov-14 8:34 

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.