Click here to Skip to main content
15,917,568 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionAutomatically starting VB 6 application at Windows Start Up Pin
RyJaBy17-Aug-09 7:02
RyJaBy17-Aug-09 7:02 
AnswerRe: Automatically starting VB 6 application at Windows Start Up Pin
Dave Kreskowiak17-Aug-09 8:07
mveDave Kreskowiak17-Aug-09 8:07 
QuestionHow to print page with Visual Basic 2008? Pin
Mohamed_Khalil17-Aug-09 6:31
Mohamed_Khalil17-Aug-09 6:31 
AnswerRe: How to print page with Visual Basic 2008? Pin
Henry Minute17-Aug-09 7:06
Henry Minute17-Aug-09 7:06 
QuestionAdding a Positive Double to Negative Double Pin
KeithF17-Aug-09 3:43
KeithF17-Aug-09 3:43 
AnswerRe: Adding a Positive Double to Negative Double Pin
Luc Pattyn17-Aug-09 4:12
sitebuilderLuc Pattyn17-Aug-09 4:12 
GeneralRe: Adding a Positive Double to Negative Double Pin
KeithF17-Aug-09 4:16
KeithF17-Aug-09 4:16 
QuestionCanceling a ThreadPool thread that's being blocked by a .NET method Pin
Brandon D. Legault17-Aug-09 3:39
Brandon D. Legault17-Aug-09 3:39 
Hello,

I have a task that needs to be executed many times in a thread, so as to keep my GUI responsive. Right now I'm using the ThreadPool to accomplish the tasks, and it works perfectly. I get all the data I expect back from the threads, life's good.

When those tasks are finished, I then fire off another set of threads to accomplish another set of tasks, in the same fashion. The work method of these threads uses a call to RegistryKey.OpenRemoteBaseKey, which does exactly that, opens a remote registry key. The problem is: if the user running the application does not have permission to open the remote registry the call will throw an IOException, but I expect this behaviour because the user does not have permission to do it. However, the call itself can take FOREVER.

I wrote the application initially to use delegate methods and used the WaitHandle.WaitOne() method on AutoResetEvents in a state object I passed to each delegate. I tried the WaitOne method using a timeout, which worked fine until I realized that even though the WaitOne timed out, the thread was still running. This is a problem because (from what I understand) processes are only given a certain number of ThreadPool threads and, once used, they must be finished in order to be released back to the threadpool. In my work method, I also have a variable that can be signalled when the thread should be stopped, but that (obviously) only works on code that I've written.

So, my question is, how can I cancel a thread that's stuck on a .NET method? Is there some sort of garbage collection method I can call if I give it a handle? There has to be a way.

I've searched Google, MSDN and everywhere in between for solutions to this, but no one has an answer.
AnswerRe: Canceling a ThreadPool thread that's being blocked by a .NET method Pin
Dave Kreskowiak17-Aug-09 4:28
mveDave Kreskowiak17-Aug-09 4:28 
GeneralRe: Canceling a ThreadPool thread that's being blocked by a .NET method Pin
Brandon D. Legault17-Aug-09 4:41
Brandon D. Legault17-Aug-09 4:41 
GeneralRe: Canceling a ThreadPool thread that's being blocked by a .NET method Pin
Dave Kreskowiak17-Aug-09 6:54
mveDave Kreskowiak17-Aug-09 6:54 
GeneralRe: Canceling a ThreadPool thread that's being blocked by a .NET method Pin
Brandon D. Legault17-Aug-09 7:43
Brandon D. Legault17-Aug-09 7:43 
AnswerRe: Canceling a ThreadPool thread that's being blocked by a .NET method Pin
Luc Pattyn17-Aug-09 14:47
sitebuilderLuc Pattyn17-Aug-09 14:47 
QuestionProject Size ? Pin
Paramu197317-Aug-09 3:13
Paramu197317-Aug-09 3:13 
AnswerRe: Project Size ? Pin
Johan Hakkesteegt17-Aug-09 3:27
Johan Hakkesteegt17-Aug-09 3:27 
QuestionHelp with automated VB script? Pin
mukkil17-Aug-09 0:27
mukkil17-Aug-09 0:27 
AnswerRe: Help with automated VB script? Pin
mukkil17-Aug-09 1:22
mukkil17-Aug-09 1:22 
QuestionRotate Label to 90° Angle Pin
Anubhava Dimri16-Aug-09 23:46
Anubhava Dimri16-Aug-09 23:46 
AnswerRe: Rotate Label to 90° Angle Pin
Johan Hakkesteegt17-Aug-09 0:11
Johan Hakkesteegt17-Aug-09 0:11 
AnswerRe: Rotate Label to 90° Angle Pin
The Man from U.N.C.L.E.17-Aug-09 2:35
The Man from U.N.C.L.E.17-Aug-09 2:35 
Questionhow to find max orderno of the same customer Pin
AjitMourya16-Aug-09 21:47
AjitMourya16-Aug-09 21:47 
AnswerRe: how to find max orderno of the same customer Pin
tosch16-Aug-09 21:55
tosch16-Aug-09 21:55 
GeneralRe: how to find max orderno of the same customer Pin
AjitMourya18-Aug-09 19:04
AjitMourya18-Aug-09 19:04 
AnswerRe: how to find max orderno of the same customer Pin
Christian Graus16-Aug-09 22:52
protectorChristian Graus16-Aug-09 22:52 
AnswerRepost Pin
Eddy Vluggen17-Aug-09 0:15
professionalEddy Vluggen17-Aug-09 0:15 

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.