Run a timer on a different thread

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have an application which does some file manipulation. While the file
manipulation takes place, the timer in the statusbar freezes.

How can I tell the timer to run on a different thread?

Also, my UI freezes if there is a big file to move. I have a label on the
form which shows the current file being copied and the number of files still
to be copied, but once a big file is encountered, it never updates these
details. The work goes on in the background, it is just the form which
doesn't update.

Can anyone suggest a reason for this and a possible solution?

Thanks,

Cashdeskmac
 
I have an application which does some file manipulation. While the file
manipulation takes place, the timer in the statusbar freezes.

How can I tell the timer to run on a different thread?

Either keep using a windows forms timer, but when the timer is
invoked, perform the operation itself on a different thread; or use a
different timer. See
http://pobox.com/~skeet/csharp/threads/timers.shtml
Also, my UI freezes if there is a big file to move. I have a label on the
form which shows the current file being copied and the number of files still
to be copied, but once a big file is encountered, it never updates these
details. The work goes on in the background, it is just the form which
doesn't update.

How are you trying to copy the file, and how are you trying to update
the UI?

Jon
 
Guess you are doing some thing in wrong. Now, change the code so that the
file manipulation is done on a seperate thread and let the timer be on the
main thread. So that you have control on both the process.

By doing this, you are file handling thread doesn't have to take control on
your winform and freeze all the controls.

For more indetail, post the code here. so that we can help you to finetune
the code.

HTH
 
Thanks, Chakravarthy. I will try running the file manipoulation on a
different thread.
 
Post back if you require any further code support. Meanwhile dont forget to
rate this post
 
Back
Top