Click here to Skip to main content
15,939,065 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Hello thare,i'm working on a real time application for smart device with C#. i want to send data every 37 millis seconde.
i did a program that send data every 37 millis-second with the function thread.sleep(37).
but when i see the data on the oscilloscope , the time between every data sent is not 37 millis-second . so i didn't send data on a real time. i want to know if there is a methode to send data exactly every 37 seconde without interruption by other processe. is there a way tow work wuth a thread and high priority.?? to make the application real time.

the goal is to send exactly the data evey 37 millis-second without interruption. i'm working on visula studio 2008, c# smart device.

thanks :)

What I have tried:

//loop here 
Updated 5-May-16 21:18pm

1 solution

You cannot do such things, because the OS is not a real-time OS. One possible solution is to plot data as a scatter plot, passing both measurement and the time stamp of measurement event. You don't have to use a real oscilloscope; you can always use the on-screen chart to show data.

Sorry, but true real-time problems are not solvable at this level. There are different solutions based on specialized hardware.

Share this answer
Jammes_Ca 5-May-16 11:13am    
I didn't understand your solution, could you give me more detail. or write me some code please, i am newer :)
Sergey Alexandrovich Kryukov 5-May-16 11:22am    
This is not a full solution, just an idea: perhaps you don't really need real time so badly. You cannot achieve any real-time qualities on this level.

Perhaps you don't need exact time, but need a correct function of some measurement values s(t), where t is time, defined in several points in time. Those points can be equidistant in time (which you cannot achieve), or not (which is quite realistic scenario). Deliver not just s-values (based on 27 millisecond assumption), but pair of numbers: signal and time. Show the points on the plot not assuming that the points in time are equidistant. It's called "scatter plot".

Is it clear?

Sergey Alexandrovich Kryukov 5-May-16 11:22am    
Jammes_Ca 5-May-16 11:30am    
i understand, but i should send data every 37ms, or the time betweene two datas is 37 seconde, because i send those data to an IR sensor, se the ir sensor he likes receving data in 37 ms intervale. the goal is the data who will be sent, they should 37ms interval between every data sent
Sergey Alexandrovich Kryukov 5-May-16 11:36am    
From your application code? Then forget about this "should", period. Sorry. You need a hardware solution.
If you describe your ultimate goals, perhaps I would advise some alternative.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900