By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,669 Members | 2,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,669 IT Pros & Developers. It's quick & easy.

remove Handle of a thread

P: n/a

I have a problem, a window display an hourglass during long

For this I start a thread and close it when finished, but handles of
the dead thread stay in memory and increase...

Thanks for help and solution

Sample of the code:

************************************************** ****************

Public Class HourGlass
Protected Shared mLeave As Boolean = True
Protected Shared mThreadHourGlass As Threading.Thread
Protected Shared mFrmHourGlass As HGForm
Protected Shared mVisible As Boolean = True
Protected Shared mImage1 As Image =
Protected Shared mImage2 As Image =

Public Shared Sub Start()
If mThreadHourGlass Is Nothing OrElse
mThreadHourGlass.ThreadState = Threading.ThreadState.Stopped Then
mVisible = True
mThreadHourGlass = New Threading.Thread(AddressOf Run)
mThreadHourGlass.Name = "HourGlass.mThreadHourGlass"
mLeave = False
mThreadHourGlass.Priority =
End If
End Sub

Public Shared Sub Show()
End Sub
Public Shared Sub Hide()
End Sub

Public Shared Sub Close()
mLeave = True
End Sub
Private Shared Sub Run()
mFrmHourGlass = New HGForm
Dim IsPic1 As Boolean = True
While Not mLeave AndAlso Not mFrmHourGlass Is Nothing
AndAlso Not mFrmHourGlass.forceClose
If IsPic1 Then
mFrmHourGlass.mPic.Image = mImage2
mFrmHourGlass.mPic.Image = mImage1
End If
IsPic1 = Not IsPic1
End While
mFrmHourGlass = Nothing
End Sub
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

You have made a complete shared program, I dont believe that the thread is
really a thread, it is just processing confirming the doevents. In my
opinion it is better to try first to make a program that is not completly
shared. Even when you find this the best approach than you are alone and
help for those things is difficult to get.

Just my thought,

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.