15,907,910 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 13245297 (Top 4 by date)
Member 13245297
1-May-18 13:31pm
View
Hi. Thanks for pointing that mistake. I will rectify it. I couldn't understand the second point properly. Right now,I am actually starting the task PubMessage when my program begins execution and it will check whether the condition(Count>512) is met every milli second and if the condition is met it will send the message. So my main program will enqueue all the data points received every milli-second and the task PubMessage will periodically dequeue the contents and send it. You have any suggestion to optimize my solution? Thanks
Member 13245297
1-May-18 13:11pm
View
Hi. Thanks for pointing that mistake out. What if I maintain a queue and enqueues it with the message read and have a task which will periodically dequeue the contents and process it? It will make sure that I wont miss any data, right? Thanks
Member 13245297
1-May-18 7:21am
View
Thanks for replying
Member 13245297
1-May-18 7:21am
View
I do the following:
1. Read data from serial port and enqueues it to a queue
ConcurrentQueue<int> queue1 = new ConcurrentQueue<int>();
queue1.enqueue(values)
2. To dequeue I use the following Task
public async Task PubMessage()
{
int waittime =1;
if (waittime != 0)
{
do
{
double[] testarray=new double[512];
if(queue1.Count>=512)
{
wavetest = new double[512];
for (int k = 0; k < 512; k++)
{
queue1.TryDequeue(out testarray[k]);
}
SendMessage(testarray);
}
await Task.Delay(waittime);
}
while (true);
}
}