|
Often, it is easier and cleaner to simply create one (or more) thread at startup that sleep until an interval occurs, does it's processing, and goes back to sleep. The debugging is easier because you are not creating and destroying threads all the time and you don't have to deal with those issues surrounding thread creation. Consider the following thread function:
DWORD WINAPI BackgroundMailBoxMonitorThread(LPVOID pParams)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
BACKGROUNDPARAMSTRUCT *pParamStruct = (BACKGROUNDPARAMSTRUCT *)pParams;
DBConnection *pDBConn = new DBConnection;
if (pDBConn)
{
int iRunFrequency = 300;
if (pParamStruct->pApplication->GetUserTagValue("MailBoxMonitorBackgroundThreadRunFrequency",caSQLBuf))
iRunFrequency = atoi(caSQLBuf);
if (iRunFrequency < 30)
iRunFrequency = 30;
pParamStruct->pApplication->GetSQLStatement(6015,caInBoxSQLBuf);
if (pParamStruct->pApplication->GetSQLStatement(6010,caSQLBuf))
{
pParamStruct->pApplication->ParseSQL(caSQLBuf);
int iSeconds = 0;
while (!pParamStruct->bTerminateThread)
{
iSeconds++;
if (iSeconds >= iRunFrequency)
{
if (pParamStruct->pApplication->Connect2DB(pDBConn))
{
DBStatement *pStmt = pDBConn->ExecSQL(caSQLBuf);
if (pStmt)
{
CObList oAccounts;
MailBoxAccountInfo *pAccount;
while (pStmt->FetchNext())
{
pAccount = new MailBoxAccountInfo;
pAccount->m_lCompanyKey = pStmt->GetLong(1);
pAccount->m_cEMailSenderAccount = pStmt->GetString(2);
oAccounts.AddTail((CObject *)pAccount);
}
pStmt->EndSQL();
delete pStmt;
POSITION pPos = oAccounts.GetHeadPosition();
while (pPos)
{
pAccount = (MailBoxAccountInfo *)oAccounts.GetNext(pPos);
if (pAccount)
{
CheckMailAccountForActivity(pAccount,pDBConn,caInBoxSQLBuf,pParamStruct->pApplication);
delete pAccount;
}
}
oAccounts.RemoveAll();
}
pDBConn->Disconnect();
iSeconds = 0;
}
}
Sleep(1000);
}
}
else
{
LogBackgroundProcessError(3,"Mailbox Monitor Company List SQL Statement Not Found!",pParamStruct->pApplication);
}
delete pDBConn;
}
if (!pParamStruct->bTerminateThread)
pParamStruct->hThread = NULL;
return 0;
}
It checks multiple mailboxes on an user-defined interval. It is NOT a UI thread, but sounds similar to what you are doing and if you need to update ui elements, you can pass messages to the foreground UI thread for screen updating.
onwards and upwards...
|
|
|
|
|
Due to the nature of this beast I have to create and destroy threads Other wise I would just create one thread per server and leave them open like you suggest..
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I am using a CtreeView, i want to know if multiselection is possible ?
(i would like to select many HTREEITEM with the Ctrl or Shift key)
ty
|
|
|
|
|
Nope. This is not possible.
Try and find on CP TreeCtrl derived class which handle this.
~RaGE();
|
|
|
|
|
This should help.. http://www.codeguru.com/treeview/multiple_sel.shtml
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
http://www.codeguru.com/treeview/multiple_sel.shtml[^]
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I use a multiline TabCtrl in my mdi app, and to add an item i use InsertItem. The problem is when a line is complete, the first new line after the call to insertitem is invisible. The user need to click on a tab button to display the second line . I think it's because when i use InsertItem, OnSizeParent is not called. So I've tried to call
MyTabCtrl.Repositionbar(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,42,reposDefault ,rcClient)
but nothing happen
Any suggestioon ? Thanks you very much..
|
|
|
|
|
Hi All
I was looking for information about how the file can tell its type not depending on the extension. I found out every file has its own identity number ( magic number ) or some sort of id for that file to easy to tell this file is pdf file, doc file, tiff file and so on...
I wonder can anyone give me the link to the list of file extension with its magic number.
such as
File type Typical extension Hex digits(xx = variable) Ascii digits(. = not an ascii char )
Bitmap format .bmp 42 4d BM
FITS format .fits 53 49 4d 50 4c 45 SIMPLE
GIF format .gif 47 49 46 38 GIF8
Graphics Kernel System .gks 47 4b 53 4d GKSM
IRIS rgb format .rgb 01 da ..
ITC (CMU WM) format .itc f1 00 40 bb ....
pdf %pdf
|
|
|
|
|
A search on google returns several resources, one of which is found here. Remember that magic numbers are not always a guarantee that the file is of that type - they are certainly not compulsary on every file, and sometimes may even be a string located anywhere in the file. If you have access to a Unix machine then you can also find another list in /etc/magic and you might find it useful to look at the code for the unix 'file' utility which tries to determine the type of a file using magic numbers
|
|
|
|
|
Thank you both but I found those links already.
<br />
Remember that magic numbers are not always a guarantee that the file is of that type - they are certainly not compulsary on every file, and sometimes may even be a string located anywhere in the file.
So what is it to tell the file type if magic number can't be guaranteed? there gotta be something that can tell the file was created by which application.
|
|
|
|
|
|
pnpfriend wrote:
there gotta be something that can tell the file was created by which application.
Not even close. A file's format is important only to the application that created it. The fact that you can open a file and find a particular signature is purely coincidental.
|
|
|
|
|
remember that nothing HAS to be as it should
try renaming a txt file to bmp and opening it in paint
u get the "invalid file format" type msg
"penguins have no bill" biz stuff about me
|
|
|
|
|
try www.wotsit.org[^] for a list of numerous file formats
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Is there a better way to increase build numbers than manually through
resources? Am I just dense?
I'm using VC++ 6.0
BW
"I don't remember, but I know we played together because I've seen the posters." - Joe Walsh talking with Ozzy Osbourne about touring together in the 70's
|
|
|
|
|
|
thanks for the link.
Why wouldn't they add that as an option under build?? Any clue?
BW
"I don't remember, but I know we played together because I've seen the posters." - Joe Walsh talking with Ozzy Osbourne about touring together in the 70's
|
|
|
|
|
brianwelsch wrote:
Why wouldn't they add that as an option under build?? Any clue?
That is a mystery to me because it is not very difficult to implemnt..
John
|
|
|
|
|
Here is another example:
http://www.flounder.com/incrementing_build_numbers.htm
|
|
|
|
|
Gracias!
BW
"I don't remember, but I know we played together because I've seen the posters." - Joe Walsh talking with Ozzy Osbourne about touring together in the 70's
|
|
|
|
|
I'm trying to use the Enhanced CPropertySheet from the "Free size and extended styles in CPropertySheets" article, but when I call CPropertySheetEnh::OnInitDialog() from my property sheet's OnInitDialog() I get the error:
CPropertySheetEnh::OnInitDialog' : illegal call of non-static member function
Anyone know why?
|
|
|
|
|
There are two causes of this error:
1. You're calling a non-static member function from a static member function
2. You're calling non-static member function as though it were a static member function.
As far as I can see, it won't be the first one. The most likely cause is that your property sheet is still derived from CPropertySheet , not CPropertySheetEnh .
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hi...I am BS student and planning to do my final year project on Implementation of Digital watermarking on image,audio and video files.
If any one know about Digital Watermarking(or its implementation gauidlines) plz help me and If any one can tell me that in which language it would be better to implement it, in VC++ or C#.
Thanx in anticipatoin.
Rizwan.
LoVe FoR aLL HaTrEd FoR NoNe
|
|
|
|
|
essentially watermarking is hiding some known data in a file such that it doesnt degrade the file at all and can be recovered by the right software ... u have to have an algorithm that tells u where to look for the watermark data that obviously u wouldnt want other ppl to find out about or they could change the watermark data and that data must not affect the data of the original file ... images and video are easier but audio can present some problems cos a single wrong data point can cause a click or pop in the playback
it wouldnt matter what language u used for the process of watermarking ... it would depend on what language u were writing the app in
"penguins have no bill" biz stuff about me
|
|
|
|
|
Hello,
I have trouble with my Combo and EditBoxes: If the InputFocus is set to a Combo or EditBox and then the ENTER-Key is pressed, the dialog disappears and in certain cases the application crashes.
How can I catch up those messages, caused by the Enter-Key to avoid this problem?
Best regards
(I have a dialog-based app with MSVC6.00 and MFC)
|
|
|
|