Pergunta

I am working on a class library that tracks transit vehicles in close to real time using GPS lat/long co-ordinates.

The library gets the vehicles positions from a rest XML web service provided by the transit service. I want the vehicle coordinates to automatically update them selves without having to manually call and update them through a refresh method in my application. The class should automatically update itself with the latest data and raise an event when it updates.

Is it possible to auto refresh the data on a timer inside of an object using a timed event or is this not possible with out running a message pump within the class

I apologize if there is an existing question for this type of thing but if there is I couldn't find it using Google or the site search.

Foi útil?

Solução

You can use a System.Threading.Timer. It doesn't need a message loop as it "Ticks" on thread pool threads. That does mean you'll have to marshal back to the UI thread to update the UI.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top