Re: timer/threading



OK; the timer (via SyncContext) fires on the UI thread. You then start
a thread, which immediately does a BeginInvoke back to the UI
thread...

At the moment you background thread is doing nothing useful; try to
split it so that it does something like:

private void liveprices()
{ // expecting this on a non-UI thread!
//TODO: go get the data into a new DataTable, array or
whatever
BeginInvoke((MethodInvoker) delegate {
//TODO: update the grid
});
}

Now the "fetch" happends on the worker thread, and the UI update
happens on the UI thread.

However, every second seems optimistic for DataTable; I'm hoping
you're using a "get changes since <x>" mechanism in the database?

And note that if your datatable is UI bound you can only touch it from
the UI thread.

Marc
.



Relevant Pages

  • Re: posix-cpu-timers revamp
    ... Tests with a process CPU timer set for a long expiration time. ... interval as set by setitimer. ... the first time it fires at the value set by setitimerbut from then on ... The current value of an itimer is a user feature, ...
    (Linux-Kernel)
  • Problem with Timer firing reliably
    ... I have an app that runs 24/7. ... timer that runs with its interval set to 1000 ms. ... Every time it fires, ... I display the time on the main screen using this statement: ...
    (microsoft.public.vb.general.discussion)
  • Re: A special (?) type of timer
    ... I'm not sure if there are any classes in the framework that will do that. ... I assume there is some unmanaged API that you can use ... instead, or you could try using a System.Threading.Timer with a 1 hour interval, for example, and after it fires each time check the ... I need to tell the timer: fire at 3:25 pm. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Check if File exists
    ... You could just put the thread to sleep, or have a timer that fires every ... but this is an expensive operation. ... Check out the FileSystemWatcher class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Threading issue -- with no threads?!?
    ... the timer is thread pool thread and you cannot update the UI ... Use the Form's Invoke or BeginInvoke ...
    (microsoft.public.dotnet.framework.windowsforms)

Loading