|
According to the documentation[^] a message queue can store 10000 messsages by default (although that can be changed). If you have 100000 unprocessed messages, I would say you have a bigger problem than merely PostMessage failing
|
|
|
|
|
Thanks for the online MSDN link. I should have checked there as it's more informative than my local copy.
Under normal use there is a filter on the query that is retrieving the data that ensures that the amount of data is much less than 10000 records. However there are extreme/unusual circumstances where the user can turn off this filter and there then could be as many as 30K to 40K records returned. I'm going to experiment with the registry setting to see if that does work, but I doubt I'll use that for a solution. Most likely I'll probably change the application so that removing the filter, which is actually a date filter, will be replaced by a filter on some other data item. Thanks.
|
|
|
|
|
Bleh - Sleep()
I'd definitely recommend using a better synchronization method.
If there's potentially that much data coming in, implementing your own FIFO queue
and not posting a message for every item should work much better.
For example - At a minimum, you could synchronize access to the FIFO queue using a critical section.
The worker thread can enter the critical section, queue an item (or several items), post the message, and leave the
critical section.
When the UI thread receives the message, it enters the critical section, processes all the queued items,
flushes all remaining user messages in the thread queue, and leaves the critical section.
That's a bare minimum, and if the data comes fast enough on the worker thread, it could still fill
the UI thread message queue, but hopefully it gives you an idea to work with.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I hear ya'. Using Sleep as a synchronization method is just a poor man's way of postponing a problem.
Thanks for the FIFO queue idea, although I think I'll end up going with replacing the filter as I mentioned to Nemanja. Thanks, Mark.
|
|
|
|
|
Even better: instead of using a message to signal new data in the FIFO, setting an event will do the trick also. That avoids to have a lot of unnecessary messages in the queue.
|
|
|
|
|
True, but what's an elegant way to check if the event is signalled on the UI thread?
Modify the message loop to use MsgWaitForMultipleObjectsEx() maybe?
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
We've got a bunch of apps that need to prepare data for a machine that uses big-endian byte order. So we have a bunch of structs that look like:
struct tagFOO_COMREG
{
UINT16 ui16DataLength_BE;
UINT32 ui32SeqNum_BE;
} FOO_COMREG_s, *PFOO_COMREG_s;
where the _BE is a reminder that these values have to be byte-swapped.
So, one day I thought it would be convenient to be able to assign to one of the struct members without having to explicitly do the byte swapping. So I wrote some classes like:
class UINT16_BE
{
private:
BYTE m_abData[2];
public:
UINT16_BE(void)
{
}
UINT16_BE(UINT16 ui16)
{
m_abData[0] = static_cast<BYTE>(ui16 >> 8);
m_abData[1] = static_cast<BYTE>(ui16);
}
operator UINT16(void)
{
return ((m_abData[0] << 8) | m_abData[1]);
}
};
And it works fine. Until my co-worker comes up to me asking how to fix a compiler error he's having. He's trying to put these in a union, which doesn't work because the constructors keep it from being recognized as POD (despite the fact that the class was designed to be memcpy-able).
So, is there a way around this?
modified on Monday, February 11, 2008 2:13 PM
|
|
|
|
|
ClementsDan wrote: He's trying to put these in a union
The constructor's not going to work there...maybe something like
this will work...
class UINT16_BE
{
private:
BYTE m_abData[2];
public:
UINT16_BE &operator =(UINT16 ui16)
{
m_abData[0] = static_cast<byte>(ui16 >> 8);
m_abData[1] = static_cast<byte>(ui16);
return *this;
}
operator UINT16() const
{
return ((m_abData[0] << 8) | m_abData[1]);
}
};</byte></byte>
Mark
Last modified: 22mins after originally posted --
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
operator UINT16(void) const
led mike
|
|
|
|
|
Fixed!
|
|
|
|
|
I need to get the count of the distinct dates from the DB which has both date and time . I use the following query . it is working in MS Access , but is failing while executing through MFC . Please let me know if anything needs to be modified.
SELECT COUNT(*) AS Field1 FROM (SELECT DISTINCT Format(Date,"dd/mm/yy") FROM Table)
|
|
|
|
|
And your code is?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
opening recordset with the sql is throwing exception
cRec.Open (AFX_DB_USE_DEFAULT_TYPE, szSql);
|
|
|
|
|
The error is " Too Few parametrs . Please specify 1 parameter
|
|
|
|
|
krishnan.s wrote: sql is throwing exception
And the exception does contain what?
A few unsorted tips from MSDN[^]
"Finally, you must not insert whitespace before the curly brace in a CALL statement or before the SELECT keyword in a SELECT statment."
"You can examine the constructed string by calling GetSQL after calling Open. For additional details about how the recordset constructs a SQL statement and selects records, see the article Recordset: How Recordsets Select Records (ODBC)."
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
krishnan.s wrote: I use the following query . it is working in MS Access
krishnan.s wrote: SELECT COUNT(*) AS Field1 FROM (SELECT DISTINCT Format(Date,"dd/mm/yy") FROM Table)
I don't see any "Format" listed in the SQL Reserved words for MS Access?
led mike
|
|
|
|
|
It is used in formattting the date time values in accesss like date_trunc() in postgres
|
|
|
|
|
SELECT COUNT(*) AS Field1 FROM (SELECT DISTINCT Format(Date,"dd/mm/yy") FROM Table)
So if that is supported in Access it becomes:
SELECT COUNT(*) AS Field1 FROM (SELECT DISTINCT 12/02/08 FROM Table)
And that runs in Access?
led mike
|
|
|
|
|
can any one help...how to add separator line in list box just like menu items separator.
|
|
|
|
|
How about:
InsertString(x, "--------------");
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If david's answer is good so AddString is good for you.
|
|
|
|
|
I thought it's already seperated
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
i can add string using m_listBox.AddString("------");
but now user is able to select ----- option.
what i want is:
i have list of items to display in list box, i want a separator in between some,and
user is not allowed to select separator line.( ----- ).
|
|
|
|
|
How do I convert INT32 to int?
For instance, INT32 nID = 10;
Thanks!
|
|
|
|
|
from MSDN.
INT32 32-bit signed integer.
This type is declared in BaseTsd.h as follows:
typedef signed int INT32;
Hence you don't even need the conversion.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|