Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

OnRecieve Help

Posted on 2003-11-25
10
Medium Priority
?
196 Views
Last Modified: 2013-11-20
I have a socket that typically recieves messages at faily low rates. However, there are times when it will be reading messages as fast as possible do to the request for a list command. The problem with this is that it seems to lock up the application so that no other messages are processed. How can I make it so that the application will still process OnRecieve messages fast, but still catch all mouse clicks, window resizing, etc.?
0
Comment
Question by:SGyves
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 2000 total points
ID: 9822407
For that you have to limit the amount of data in one receive to minimun and apply a loop.

and in that loop, place this code

         MSG msg;

         while ( ::PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE) )
         {
              ::TranslateMessage(&msg);
              ::DispatchMessage(&msg);
         }


Good Luck
0
 

Author Comment

by:SGyves
ID: 9825823
I tried that...but I can't even see the mouse in the window area of my application when I add this code to OnRecieve. Any other advice rosh?
0
 
LVL 4

Expert Comment

by:inox
ID: 9830934

the problem you have may be that the processing of the data received is slower than the receiving. In that case "OnReceive" messages are stacked, and then the messagedispatching also does not help. Can you ommit the "processing of the data received" for test reasons to see if UI works better? (so the right steps to be made later)
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

Author Comment

by:SGyves
ID: 9832480
Yes...of course if I omitt the prcessing of data...it solves it. It is only under heavy recieve conditions that this happens.
0
 
LVL 4

Expert Comment

by:inox
ID: 9837006

well this was expected (but it could be possible that the application is busy doing other things also) so the load comes from telegramreceiving and processing
unfortunately now things may become a bit complicated serveral questions are meaningful to find the best way
- can the telegram data processing be done delayed or must it be 'just in time'
- if jit can the telegram data processing split in jit part and delayable part
- how is the frequecy evenly spread or batch-wise

I think the best way to perform heavy socket traffic is:
- do it in a seperate thead
- prefer Windows Sockets library to MFC
- split job for telegramprocessing in an immediate excecution and queue datas in a collection (list) for later processing (idle-time)
depending on needs this may be simplified
0
 

Author Comment

by:SGyves
ID: 9855514
Well it would seem to be fine to hold all other operations and to make recieving a low priority. Meaning...as long as there is nothing from the UI to process....go ahead and recieve. It will suck if I have to move it back into its own thread. That is the way i had it before...and that spawned a whole other set of problems.
0
 
LVL 4

Expert Comment

by:inox
ID: 9858617

I recommend to do communication in a seperate thread using the socket api.
I understand that you don't want to do this but you won't have great influence on how messages (receiving and UI) are queued and processed in Messageloop.
Maybe it helps if you create a thread in the OnReceive-handler and do just dataprocessing there.
0
 

Author Comment

by:SGyves
ID: 9897892
So there is no way for my program to make sure it processes UI messages while all of this reciveing is going on? You know, I have had this socket in and out of a thread a number of times. Each method posed new problems that no one can seem to solve. Let me explain the situation a little better. The only instance that creates an overload problem is when someone requests a list of channels from the server...and that server has hundreds of channels to send. Otherwise...the program does okay. Why is it that the mouse cursor can not leave the window when we put a message pump inside of OnRecieve???
0
 

Author Comment

by:SGyves
ID: 9897935
Thank you rosh for the solution. It didn't work at first when I placed the message pump right in the OnRecieve() functions. But all was good when I moved the data processing to a separate function and put the message pump in that function. Simple...easy....no more headache.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9901662
Thankx
Sorry for the delay, I was not here

Rosh :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question