If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Asynchronous reading

sir, can you tell me how to post a new topic here? i want to ask about what i should do for my Gravitational Search algorithm distance, a way of computing it for solving 0/1 multidimensional knapsack ... please..

Re: Asynchronous reading

For serial port reading, I'd recommend going the Overlapped I/O route and do all the port reading from a secondary thread. Search bing or google for serial port class implementations that will do this for you.

While you can use the polling Timer approach, I wouldn't recommend it because the Timer approach uses windows messages and message queue. If the timer polling occurs in the main UI thread, then user operations such as moving the mouse or resizing a window can interrupt the polling resulting in a loss of serial port data.

Of course you can put the timer into a second thread, but if you do this you might as well take it one step further and eliminate the polling all together by going with the Overlapped I/O route.

Re: Asynchronous reading

Originally Posted by emidevil

sir, can you tell me how to post a new topic here? i want to ask about what i should do for my Gravitational Search algorithm distance, a way of computing it for solving 0/1 multidimensional knapsack ... please..

You can't post a new thread topic from inside an existing thread. So you need to back out into the forum the thread is in and then you'll see a "Post a new thread" button near the top left of the forum. For example, this thread is in the "Visual C++ Forum". Just click on the "Visual C++ Forum" breadcrumb at the top of this thread. That will take to you the forum, then just click on the "Post a new thread" button.

Re: Asynchronous reading

Re: Asynchronous reading

Well, if it's a Windows Forms app, I'd recommend you make use of the SerialPort class' DataReceived event. That way the class will handle the asynchronuous operation internally for you, and you get the opportunity to pick up received data when it arrives.

However, in this case you have posted in the wrong forum section. Windows Forms apps are C++/CLI (as opposed to native C++), which is discussed in a separate forum section.

I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.