Resolved Help. Timer on form not working. Can't figure out why.


Sep 30, 2020
Programming Experience
I needed to create a Copy Dialog from scratch. It will (I hope) show the file/folder being copied with a Copy Animation (similar to the default UIDialog.)

I created a form and put a PictureBox & Timer on it. I set the Timer default to Enabled and Interval to 150. Code was added (below) to the "_Tick" event to change the picbox source image (5 frames.)

When I run my program, and perform a frmCopyAni.Show (followed by some file copy commands), the form appears and the computer starts copying in the background, but the timer never runs (I put a break in the Tick event but it's never triggered.) I added Timer.Enabled to Form_Load but it didn't help.

Timer start/end:
            BackupData()                    ' Backup settings.


Public Class frmCopy

    Private Sub frmCopy_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        intTick += 1
        If intTick > 5 Then intTick = 1
        picCopyAni.Image = imgCopyAni.Images.Item(intTick)
    End Sub

End Class

I'm not sure what I'm doing wrong (if anything.) I think the timer won't run while FileCopy is taking place. Any help is appreciated.
Last edited:
If you are doing the copying on the UI thread then it's too busy doing that to raise and handle the Tick event. You would need to be doing the copying on a secondary thread.
Thx for the reply. Here is my Copy code:

        For Each myFile In Directory.GetFiles(strPath & "Save", "Data*.*")
                My.Computer.FileSystem.CopyFile(myFile, strBackupPath & My.Computer.FileSystem.GetName(myFile), True)   ' Must trim path from source file otherwise Crash. No idea why. Using Win copy dialog prompts to overwrite EVERY SINGLE FILE.
                intCnt += 1
                frmCopy.lblFileNum.Text = intCnt.ToString
                frmCopy.lblSrcCopy.Text = myFile.ToString
                ' Attempting to copy "~Temp" files causes an error after the fact. Ignore.
            End Try

I'm not sure how to perform a "secondary" thread.
Just to reverse the direction ... rather than solve the problem that you think you're having, what are you trying to solve? Why are you having a timer kick off during a copy operation?
Can you explain the 'I'm trying to ....' ?

I'm worried you're asking how to get to Brighton from Sheffield, but in reality, you're trying to get to Devon.
I'm not sure what your question is but the problem has been resolved.

I had to create a custom copy dialog b/c the built-in Copy function that includes the animated Windows progress indicator stops & prompts to "overwrite" every duplicate file b/c there is no "overwrite" switch using this method.

I wanted my copy operation to include an animation & display filenames so the user isn't just staring at a Busy icon for seven minutes. And the only way to do this was to put the animation in a separate thread during the copy process.
> but the problem has been resolved

Oh ... it helps if you mark the thread as 'Answered' or 'Resolved' and finalise it, otherwise idiots like me think its' still open and try and help. :|
Does an animation really help when copying? Is a user going to stare at your screen constantly for seven minutes? So long as there is a progress indication (file x of y) the user is going to alt+tab and do something else, surely?
My apologies. My question was eventually answered on another site and I forgot to close my post over here.

The animation looks nice & more professional, but more than that, if you don't use multiple threads, even just displaying the filenames doesn't work as the form does not update when it is busy copying.

People get anxious and start wondering if the program crashed if there is no indication of activity in as little as 30 seconds.