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

C#

 
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 
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 
I think what I'm trying to do is pretty reasonable.

Worker is actually a service (think service in the sense of Dependency Injection or Service Locator pattern) that services a queue. I don't know when (or if) messages will get thrown into the queue, so the queue needs to be monitored for the life of the process (its a blocking queue). If Worker was a background task, I would either need the app to implement some kind of "wait for all the messages to be processed" behavior or have messages lost.

In fact, if I make the Worker a background thread and have the console app send a 1000 messages into the queue, the process would exit after only 1 or 2 of the messages were serviced. NOT DESIRABLE.

So while I stripped all that out of my examples, the real intention is for the watch dog task to wait for the main thread to shutdown AND all the remaining messages in the queue to be processed and then set "b = true" so the worker thread can shut down (which makes the process shutdown cleanly).

Not too unreasonable, huh? Smile | :)

Like I said in another response (I think to Eddy)... when I make reusable APIs, I like to encapsulate all the behavior / requirements / code I can into the class so the user of my API can use it in a simple way.
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 
GeneralRe: Waiting for thread to exit? Pin
SledgeHammer0110-Nov-14 9:27
SledgeHammer0110-Nov-14 9:27 
GeneralRe: Waiting for thread to exit? Pin
Eddy Vluggen11-Nov-14 0:31
professionalEddy Vluggen11-Nov-14 0:31 
AnswerRe: Waiting for thread to exit? Pin
Garth J Lancaster8-Nov-14 17:31
professionalGarth J Lancaster8-Nov-14 17:31 
QuestionAny library to decompress XZ files? Pin
DonRolando8-Nov-14 9:56
DonRolando8-Nov-14 9:56 
AnswerRe: Any library to decompress XZ files? Pin
Garth J Lancaster8-Nov-14 12:11
professionalGarth J Lancaster8-Nov-14 12:11 
QuestionSystem.Web.HttpContext cannot be serialized because it does not have a parameterless constructor. Pin
ASPnoob8-Nov-14 4:33
ASPnoob8-Nov-14 4:33 

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.