I have a program that checks a streaming data feed every 5 seconds, then makes some calculations and then fires some events, then back to checking data. What is the best way(most efficient) way to do this. Here is my basic structure, however my program freezes after running for more than a few hours(I want to run it 24 hrs a day) I know that multithreading is needed but not sure how to do this.
Basic structure:
Main program
Get Data
Calculations
Do events
loop back to Get Data
Thanks in advance.

How to check a data stream every 5 seconds
deyanp
Thanks
cmsmith81
you would be advised to use a Timer and set the interval to every 5 seconds (timer interval is measured in ms) and then do your data checking there and raise events or whatever.
depending on what you are doing, you may require to spin up another thread to check the data and perhaps do the timer interval in there than the main thread (UI thread).
Generally the timer should be used. Can you tell us what the application does From this, we can then help you in deciding if you require another thread to do your calcs/raising events in
Fran Garcia
sure. Well yes threading is required here. Take a look here more about threading:
http://msdn2.microsoft.com/en-us/library/system.threading.threadstart.aspx
http://msdn2.microsoft.com/en-us/library/system.threading.parameterizedthreadstart.aspx