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
Hello

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

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 =
Model.Image("hourglass1.bmp")
Protected Shared mImage2 As Image =
Model.Image("hourglass2.bmp")

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 =
Threading.ThreadPriority.BelowNormal
mThreadHourGlass.Start()
End If
End Sub

Public Shared Sub Show()
Start()
End Sub
Public Shared Sub Hide()
Close()
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
Application.DoEvents()
If IsPic1 Then
mFrmHourGlass.mPic.Image = mImage2
Else
mFrmHourGlass.mPic.Image = mImage1
End If
IsPic1 = Not IsPic1
Threading.Thread.Sleep(250)
End While
mFrmHourGlass.Dispose()
mFrmHourGlass = Nothing
End Sub
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Spielman,

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,

Cor
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.