Click here to Skip to main content
15,890,186 members
Home / Discussions / C#
   

C#

 
GeneralRe: XML Tree View - Please Guide. Pin
Ed.Poore14-Nov-06 3:01
Ed.Poore14-Nov-06 3:01 
GeneralRe: XML Tree View - Please Guide. Pin
ejuanpp14-Nov-06 3:24
ejuanpp14-Nov-06 3:24 
QuestionHow to self recall after a time interval Pin
t2o2uk14-Nov-06 2:14
t2o2uk14-Nov-06 2:14 
AnswerRe: How to self recall after a time interval Pin
Martin#14-Nov-06 2:22
Martin#14-Nov-06 2:22 
GeneralRe: How to self recall after a time interval Pin
Martin#14-Nov-06 2:28
Martin#14-Nov-06 2:28 
AnswerRe: How to self recall after a time interval Pin
Guffa14-Nov-06 2:29
Guffa14-Nov-06 2:29 
QuestionBackgroundWorker CancelSync() ?? Pin
Chris_Green14-Nov-06 2:12
Chris_Green14-Nov-06 2:12 
AnswerRe: BackgroundWorker CancelSync() ?? Pin
Judah Gabriel Himango14-Nov-06 8:51
sponsorJudah Gabriel Himango14-Nov-06 8:51 
There isn't a way, no. You can terminate the thread via Thread.Abort, but that's generally a bad idea since it can leave your code in a volatile, unstable state.

I recommend having your background worker spawn a new thread in the DoWork handler. Have that thread do the actual work, while the DoWork thread do 2 things: continually check for the cancel flag, and continually watch for completion of the spawned thread. When either the spawned thread finishes or the cancel flag is true, your DoWork thread can return, thus your RunWorkerCompleted handler will be fired.

p.s. check out Roy Osherove's extended BackgroundWorker[^], which includes a CancelImmediately() method that accomplishes pretty much what you're trying to do.


Tech, life, family, faith: Give me a visit.
I'm currently blogging about: God-as-Judge, God-as-Forgiver
The apostle Paul, modernly speaking: Epistles of Paul

Judah Himango


QuestionEPS file from TChart Pin
haritus14-Nov-06 1:51
haritus14-Nov-06 1:51 
Questionfixed width tootips Pin
Mridang Agarwalla14-Nov-06 1:01
Mridang Agarwalla14-Nov-06 1:01 
QuestionRandom Class issue Pin
Russell Jones14-Nov-06 0:42
Russell Jones14-Nov-06 0:42 
AnswerRe: Random Class issue Pin
Guffa14-Nov-06 1:02
Guffa14-Nov-06 1:02 
GeneralRe: Random Class issue Pin
Russell Jones14-Nov-06 1:09
Russell Jones14-Nov-06 1:09 
AnswerRe: Random Class issue Pin
Guffa14-Nov-06 4:36
Guffa14-Nov-06 4:36 
Questionchange current datagridview row style Pin
gus_br14-Nov-06 0:36
gus_br14-Nov-06 0:36 
AnswerRe: change current datagridview row style Pin
mark_w_14-Nov-06 2:38
mark_w_14-Nov-06 2:38 
QuestionWinforms: how to wrap image and text together Pin
OGG029348083614-Nov-06 0:27
OGG029348083614-Nov-06 0:27 
AnswerRe: Winforms: how to wrap image and text together Pin
led mike14-Nov-06 5:07
led mike14-Nov-06 5:07 
Questioncalling a webmethod Pin
saqib8214-Nov-06 0:23
saqib8214-Nov-06 0:23 
AnswerRe: calling a webmethod Pin
Mircea Puiu14-Nov-06 1:23
Mircea Puiu14-Nov-06 1:23 
QuestionConfigurationManager problem Pin
ranandbe13-Nov-06 23:55
ranandbe13-Nov-06 23:55 
AnswerRe: ConfigurationManager problem Pin
Ed.Poore14-Nov-06 0:19
Ed.Poore14-Nov-06 0:19 
QuestionAccess to the path 'C:\\Program Files\\AAA' is denied." Pin
ranandbe13-Nov-06 23:48
ranandbe13-Nov-06 23:48 
AnswerRe: Access to the path 'C:\\Program Files\\AAA' is denied." Pin
Ed.Poore14-Nov-06 0:19
Ed.Poore14-Nov-06 0:19 
Question.Net 2.0 operation IIS question,help me! Pin
KSCsoft13-Nov-06 23:19
KSCsoft13-Nov-06 23: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.