Click here to Skip to main content
16,007,932 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Skipping Some queries and conditions Pin
jishbalan14-Feb-09 5:07
jishbalan14-Feb-09 5:07 
GeneralRe: Skipping Some queries and conditions Pin
Dave Kreskowiak15-Feb-09 3:53
mveDave Kreskowiak15-Feb-09 3:53 
Question"Send and Receive message" -Threading Problem Pin
scothyhut13-Feb-09 19:03
scothyhut13-Feb-09 19:03 
AnswerRe: "Send and Receive message" -Threading Problem Pin
Dave Kreskowiak14-Feb-09 1:02
mveDave Kreskowiak14-Feb-09 1:02 
GeneralRe: "Send and Receive message" -Threading Problem Pin
scothyhut14-Feb-09 1:37
scothyhut14-Feb-09 1:37 
GeneralRe: "Send and Receive message" -Threading Problem Pin
Dave Kreskowiak15-Feb-09 3:48
mveDave Kreskowiak15-Feb-09 3:48 
QuestionThreading Pin
Cory Kimble13-Feb-09 7:11
Cory Kimble13-Feb-09 7:11 
GeneralRe: Threading Pin
Luc Pattyn13-Feb-09 7:45
sitebuilderLuc Pattyn13-Feb-09 7:45 
Hi Cory,

this is so wrong.
It is almost always a bad idea to abort a thread since you typically don't know what it is doing at that specific point in time, and resources may be locked, memory allocated, etc.

In this particular case, aborting the thread stops the message pump that was keeping the
progress dialog alive (the pump is a loop running inside the ShowDialog method); by aborting the thread, the dialog just sits there, completely dead, what piece of code would be responsible of removing it?

The correct way to handle this is by:
1. putting the time-consuming stuff in a thread or a BackgroundWorker (BGW are available since .NET 2.0), which you want to run to completion, hence no abort necessary;
2. showing the progress dialog in the normal manner, without using an extra thread.
3. letting the thread/BGW signal the progress dialog when it is done (this obviously requires caution about cross-thread violations, automatically solved by BGW, and solvable with Control.InvokeRequired/Control.Invoke on regular threads.
4. you may add real progress indication in the dialog; again a BGW is helping there
5. you may want to add a Cancel button; the proper way to handle a cancel request is by having the background job done in a collaborative way, typically by periodically checking a "please cancel" flag. Don't use Thread.Abort if you don't have to!

I strongly suggest you study some BackgroundWorker examples.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


QuestionWhy can't I see one of the reference (dll) file name within imports? Pin
JUNEYT13-Feb-09 6:23
JUNEYT13-Feb-09 6:23 
AnswerRe: Why can't I see one of the reference (dll) file name within imports? Pin
vaghelabhavesh13-Feb-09 6:30
vaghelabhavesh13-Feb-09 6:30 
QuestionHow to extend a generic type like KeyValuePair(of TKey, TValue)? Pin
Jon_Boy13-Feb-09 5:45
Jon_Boy13-Feb-09 5:45 
AnswerRe: How to extend a generic type like KeyValuePair(of TKey, TValue)? Pin
Gideon Engelberth13-Feb-09 6:20
Gideon Engelberth13-Feb-09 6:20 
GeneralRe: How to extend a generic type like KeyValuePair(of TKey, TValue)? Pin
Jon_Boy13-Feb-09 6:30
Jon_Boy13-Feb-09 6:30 
GeneralRe: How to extend a generic type like KeyValuePair(of TKey, TValue)? Pin
Scott Dorman13-Feb-09 9:30
professionalScott Dorman13-Feb-09 9:30 
GeneralRe: How to extend a generic type like KeyValuePair(of TKey, TValue)? Pin
Jon_Boy16-Feb-09 6:14
Jon_Boy16-Feb-09 6:14 
QuestionEvents Pin
CodingYoshi13-Feb-09 4:34
CodingYoshi13-Feb-09 4:34 
AnswerRe: Events Pin
Dave Kreskowiak13-Feb-09 4:43
mveDave Kreskowiak13-Feb-09 4:43 
GeneralRe: Events Pin
CodingYoshi13-Feb-09 8:09
CodingYoshi13-Feb-09 8:09 
GeneralRe: Events Pin
Dave Kreskowiak13-Feb-09 9:37
mveDave Kreskowiak13-Feb-09 9:37 
QuestionReflection with local variables Pin
Clay Walnum13-Feb-09 3:30
Clay Walnum13-Feb-09 3:30 
GeneralRe: Reflection with local variables Pin
Luc Pattyn13-Feb-09 4:45
sitebuilderLuc Pattyn13-Feb-09 4:45 
GeneralRe: Reflection with local variables Pin
Clay Walnum13-Feb-09 5:39
Clay Walnum13-Feb-09 5:39 
GeneralRe: Reflection with local variables Pin
Gideon Engelberth13-Feb-09 6:25
Gideon Engelberth13-Feb-09 6:25 
AnswerRe: Reflection with local variables Pin
Dave Kreskowiak13-Feb-09 5:06
mveDave Kreskowiak13-Feb-09 5:06 
GeneralRe: Reflection with local variables Pin
Clay Walnum13-Feb-09 5:48
Clay Walnum13-Feb-09 5:48 

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.