Click here to Skip to main content
15,902,634 members
Home / Discussions / C#
   

C#

 
GeneralRe: Threaded library design Pin
Luc Pattyn17-Jan-08 11:23
sitebuilderLuc Pattyn17-Jan-08 11:23 
GeneralRe: Threaded library design Pin
invictus317-Jan-08 11:34
invictus317-Jan-08 11:34 
GeneralRe: Threaded library design Pin
Ed.Poore17-Jan-08 11:41
Ed.Poore17-Jan-08 11:41 
JokeRe: Threaded library design Pin
Luc Pattyn17-Jan-08 11:52
sitebuilderLuc Pattyn17-Jan-08 11:52 
GeneralRe: Threaded library design Pin
invictus317-Jan-08 20:54
invictus317-Jan-08 20:54 
GeneralRe: Threaded library design Pin
Luc Pattyn18-Jan-08 1:52
sitebuilderLuc Pattyn18-Jan-08 1:52 
GeneralRe: Threaded library design Pin
invictus320-Jan-08 7:01
invictus320-Jan-08 7:01 
GeneralRe: Threaded library design Pin
Luc Pattyn20-Jan-08 10:21
sitebuilderLuc Pattyn20-Jan-08 10:21 
Hi,

here are some ideas:

if the thread you want to stop can cooperate, then that is the best way; e.g. have a
bool flag indicating it should stop, and have it periodically test that flag. Maybe
give timeouts to your I/O operations so it will effectively check the flag.

if that is not possible, try sending an interrupt to the thread, which should result
in an interrupt exception, then clean up in the catch block.

if that does not work, you would have to abort the thread, leading to a possible
unknown state of some objects it created, them not being disposed, etc. A possible solution
here is to have two threads, one that creates and manages objects (and does not get aborted),
the second one not creating/disposing but just using those objects; then have the main thread
signal the first thread (again with a bool), and abort the second.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.


GeneralRe: Threaded library design Pin
invictus320-Jan-08 10:38
invictus320-Jan-08 10:38 
GeneralRe: Threaded library design Pin
GuyThiebaut17-Jan-08 11:42
professionalGuyThiebaut17-Jan-08 11:42 
QuestionExcel Chart from Office 2002 Pin
springtime5417-Jan-08 10:39
springtime5417-Jan-08 10:39 
GeneralRe: Excel Chart from Office 2002 Pin
Paul Conrad17-Jan-08 13:30
professionalPaul Conrad17-Jan-08 13:30 
QuestionProblem with .Net-Remoting Pin
Opa Knack17-Jan-08 9:48
Opa Knack17-Jan-08 9:48 
GeneralDate Pin
simworld17-Jan-08 8:20
simworld17-Jan-08 8:20 
GeneralRe: Date Pin
Luc Pattyn17-Jan-08 8:53
sitebuilderLuc Pattyn17-Jan-08 8:53 
GeneralRe: Date Pin
PIEBALDconsult17-Jan-08 12:21
mvePIEBALDconsult17-Jan-08 12:21 
GeneralBitBlt Problem Pin
Richard Blythe17-Jan-08 7:56
Richard Blythe17-Jan-08 7:56 
GeneralRe: BitBlt Problem Pin
Guffa17-Jan-08 8:58
Guffa17-Jan-08 8:58 
GeneralRe: BitBlt Problem Pin
Skippums17-Jan-08 10:31
Skippums17-Jan-08 10:31 
GeneralConfiguration framework Pin
hansipet17-Jan-08 7:34
hansipet17-Jan-08 7:34 
GeneralRe: Configuration framework Pin
Gareth H17-Jan-08 10:24
Gareth H17-Jan-08 10:24 
GeneralRe: Configuration framework Pin
hansipet17-Jan-08 22:50
hansipet17-Jan-08 22:50 
GeneralCan't get 24 bit audio to play with directsound Pin
kshet2617-Jan-08 7:19
kshet2617-Jan-08 7:19 
GeneralRe: Can't get 24 bit audio to play with directsound Pin
martin_hughes17-Jan-08 9:15
martin_hughes17-Jan-08 9:15 
GeneralRe: Can't get 24 bit audio to play with directsound Pin
kshet2617-Jan-08 9:19
kshet2617-Jan-08 9:19 

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.