S
spielmann
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
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