G
Guest
I've tried changing my animator user control to run of off a separate thread, but it acts like it is still sharing the main thread and freezes whenever the main code is blocked
Maybe this is because I am doing all of this inside of one user control? All of the MSDN samples define the callback proc in a separate module. Is this a requirement? Or maybe I am running into trouble because I am referencing class module-level variables inside of my callback proc
Here's what I have (stripped down for a shorter posting)
Public Class AnimatedPictureBox
Inherits System.Windows.UserContro
Private AnimateDelegate as System.Threading.TimerCallBac
Private AnimateTimer as System.Threading.Time
Private CurrentCellNumber as Integer
private StaticCellNumber as Integer
...
Later, in the same clas
Public Sub StartAnimation(
Me.StopAnimation ' clear any previous calls
AnimateDelegate = New System.Threading.TimerCallBack ( AddressOf Me.Animate
AnimateTimer = New System.Threading.Timer ( AnimateDelegate, Nothing, 1, 55
End Su
Public Sub Stop Animation(
AnimateDelegate = Nothin
AnimateTimer = Nothin
DisplayImage (StaticCellNumber
End Su
' the callback pro
Private Sub Animate()
CurrentCellNumber +=
If CurrentCellNumber = StaticCellNumber Then CurrentCellNumber +=
If CurrentCell >= Me.ImageList.Images.Count Then CurrentCellNumber =
DisplayImage (CurrentCellNumber
End Sub
Private Sub DisplayImage(ByVal CellNumber as Integer
Me.PictureBox.Image = Me.ImageList.Images(CellNumber
Me.PictureBox.Invalidate ' force a paint to show the new imag
End Sub
End Class
Maybe this is because I am doing all of this inside of one user control? All of the MSDN samples define the callback proc in a separate module. Is this a requirement? Or maybe I am running into trouble because I am referencing class module-level variables inside of my callback proc
Here's what I have (stripped down for a shorter posting)
Public Class AnimatedPictureBox
Inherits System.Windows.UserContro
Private AnimateDelegate as System.Threading.TimerCallBac
Private AnimateTimer as System.Threading.Time
Private CurrentCellNumber as Integer
private StaticCellNumber as Integer
...
Later, in the same clas
Public Sub StartAnimation(
Me.StopAnimation ' clear any previous calls
AnimateDelegate = New System.Threading.TimerCallBack ( AddressOf Me.Animate
AnimateTimer = New System.Threading.Timer ( AnimateDelegate, Nothing, 1, 55
End Su
Public Sub Stop Animation(
AnimateDelegate = Nothin
AnimateTimer = Nothin
DisplayImage (StaticCellNumber
End Su
' the callback pro
Private Sub Animate()
CurrentCellNumber +=
If CurrentCellNumber = StaticCellNumber Then CurrentCellNumber +=
If CurrentCell >= Me.ImageList.Images.Count Then CurrentCellNumber =
DisplayImage (CurrentCellNumber
End Sub
Private Sub DisplayImage(ByVal CellNumber as Integer
Me.PictureBox.Image = Me.ImageList.Images(CellNumber
Me.PictureBox.Invalidate ' force a paint to show the new imag
End Sub
End Class