|
Anonymous wrote:
if both thread A and B access commonfunction()
will local variable, 'i' corrupt?
No, because as I said, each thread has their own stack, so each thread have independent copies of the local variables
So, the loop is performed two times independently by the two threads.
This function is also reentrant, because it don't use static neither global variables.
Resumming , no problems at all if you only use local variales
HTH
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
|
|
|
|
|
I have done a db program.Using ado to access oracle806 db,I used Oracle OleDB provider to improve performance.
It's fine on my pcs(xp/98,oracle 817 client) .However ,
After release it(using vc++6.0 install shield),it does not work on some pcs.It seem program do not connect to oracle.
On others,it work well.Try connecting the oracle with SQL*PLUS,i find the net8 is ok.What's wrong with my program? I suppose the program is Oracle OleDB provider.
Help me ,please.
|
|
|
|
|
sages wrote:
,I used Oracle OleDB provider to improve performance.
The Microsoft one is slower, but it doesn't leak memory. If you tie yourself to it now, you'll have a slower, but more reliable database.
sages wrote:
I suppose the program is Oracle OleDB provider.
Probably, yes. Be careful though - every Oracle patch comes with the full Oracle installation program, and running a patch could mean you can not ever remove Oracle using an uninstaller, plus it's almost certain that the Oracle Enterprise Manager will stop working on the machine in question. The same is true if you do an MDAC upgrade, but 2.7 does fix the memory leak I mentioned earlier ( at the expense of never being able to run the Enterprise Manager again ).
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
The Oracle OLEDB provider has been changed to MS OLEDB provider.It's OK.Thanks you for your help.good luck to u.
|
|
|
|
|
Hyello,
I have a Wizard in my application which works flawlessly on Windows 2000/Xp, but under Windows 98, I get some weird stuff going on. On some pages, when you hit the Next button, it advances either back to the beginning, or some other page other than the next one --- though it does work sometimes.
Has any run into this problem? I've been trying to trace the problem through in Windows 98, but the whole os tends to lock up and it's really frustrating!
Thanks!
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
can anyone tell me how i can disable selection of individual rows of a listctrl.
if u suggest ODS_DISABLED
please elaborate
cause i cant get it to work properly..
|
|
|
|
|
i believe you have to implement this yourself
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
do u remember the vstudio 6 help
the msdn then had the index and u could filter the list box accoring to language like for vc vb ...etc..and according to the filter all the contents not in that language would be disabled(grayed out)..
thats the kind of thing im talking off..
do umean to say that that not possible standardly and has to be implemented seperately??
|
|
|
|
|
yep, as far as i know. it's not that hard to do though... there's a bunch of articles on how to do stuff like this here in codeproject. you could also do a search for CListCtrl::DrawItem().
cheers,
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Handle LVN_ITEMCHANGING. Examine the iItem and uNewState members of the struct you are passed, and if an item is becoming selected, and you don't want it to be, return TRUE from the handler to prevent the change.
--Mike--
"alyson hannigan is so cute it's crazy" -- Googlism
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
please elaborate if possible
a code snipet would be helpful
|
|
|
|
|
I have never gotten an error in release mode that I did not get in debug mode. In CView::OnFilePrint() somewhere between OnBeginPrinting and OnPrepareDC (the two functions I can override and put some message boxes in so I can see where I am while in release mode) I am getting this:
Unhandled exception at 0x0050f277 in Paradigm.exe: 0xC0000005: Access violation reading location 0x00000002.
I have exhausted my knowledge trying to figure out why this is happening.
I can set a breakpoint for this address and it hits it three other times during execution before it bombs in OnFilePrint(). VS says there is no source code associated with this address. The dissassembly is as follows:
0050F277 66 81 7B 02 FF FF cmp word ptr [ebx+2],0FFFFh
Where do I go from here? I'm sure there are things to do that are outside my knowledge base. It works perfectly in debug mode.
Ed
|
|
|
|
|
There is a good article here on CP about how to fool the debug version into thinking it's a release version, so you can catch these errors in the debugger.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Greetings all,
I have a question. I'm using Norm Almond's CLabel control on a Property Page. I want to allow the user to select some colors and then have a rectangle on the dialog with the color the user chose. It was working perfectly as a CDialog.
What's happening now is I'm trying to make that dialog a PropertyPage as part of a PropertySheet. Here are the changes I made to InitInstance:
BOOL CPropertySheetDemoApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
/*CPropertySheetDemoDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}*/
CPropertySheet mySheet;
CMyPropertyPage myDemoPage;
myDemoPage.m_lblTest.SetBkColor(RGB(1.0, 1.0, 1.0));
mySheet.AddPage(&myDemoPage);
mySheet.DoModal();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
As you can see I just commented out the stuff to bring up the initial dialog and am trying to bring up the property sheet instead. The error I'm getting is a debug assertion failure in the UpdateSurface() method of the CLabel class. It seems to be complaining that the window hasn't been drawn or doesn't have an hWnd yet.
Any suggestions? I just want to be able to initialize the colors on the labels as they come up, and they may not always be the same colors.
I'd appreciate any suggestions!
Joe
|
|
|
|
|
Hi!!
I have a connection between two computers, that work's OK. Command NETSTAT show the ESTABLISHED status under this connection, but I need to receive from a third computer. On the 3rd computer, the NETSTAT command show the ESTABLISHED status too, but the CSocket::Receive from the server, can not listen from there...
what was wrong?
Thank's.... Walote
|
|
|
|
|
Hello,
I have a UI thread and I do a PostMessage from the thread to the application with the lParam set as a CString.. in my receiving function i do a
LRESULT CMainFrame::OnMarkOffLine(WPARAM wParam, LPARAM lParam)
{
CString* name = (CString*)lParam;
CString strName = *name;
..SNIP........
but i am getting a access violation here...
CString::CString(const CString& stringSrc)
{
ASSERT(stringSrc.GetData()->nRefs != 0); <-Here
if (stringSrc.GetData()->nRefs >= 0)
{
ASSERT(stringSrc.GetData() != _afxDataNil);
m_pchData = stringSrc.m_pchData;
InterlockedIncrement(&GetData()->nRefs);
}
else
{
Init();
*this = stringSrc.m_pchData;
}
}
What am I doing wrong??
|
|
|
|
|
There is nothing inherently wrong with the code you posted (although I would recommend that you replace the C-style typecast with a more appropriate C++ typecast but that's another matter altogether). Show us the code that sends (or posts) this message.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Here's the PostMessage
PostMessage(this->GetMainWnd()->GetSafeHwnd(),UWM_OFFLINE,0,(LPARAM)&m_strDns);
|
|
|
|
|
CString name = (LPCSTR)lParam;
instead of the
CString* name = (CString*)lParam
|
|
|
|
|
Actually the error went away but the string contains garbage..
|
|
|
|
|
I know exactly what your problem is!
You can't use pointers to objects with a PostMessage(), because PostMessage() does not hang the calling thread and wait until the receiving thread processes the message, unlike SendMessage(). What happens is that the CString object in your calling thread gets destroyed before the receiving thread gets a chance to access the strings contents.
The solution to this is kind of a pain. You need to create a central map / list container that holds a bunch of strings, and then pass handles (or even pointers) to those strings in your messages. Then you delete the string once you receive the message, or perhaps after some time.
Hope this helps!
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
When using PostMessage with non-primitive data types, alwaysuse a deep copy of the object - passing a reference to an object that might cease to exist before the message is handled is just asking for trouble:
CString * lp = new CString(m_strDns);
if (!PostMessage(...,...,..., (LPARAM) lp))
delete lp;
the error handler avoids a memory leak (although you might be tempted to retry posting the message if your handling would break down otherwise)
the message handler needs to delete the object again:
CString* name = (CString*)lParam;
_ASSERTE(name!=NULL)
CString strName = *name;
delete name;
This solution is IMO easier than the one suggested in the post above..
*) reason:
skulls don't kiss for an explanation - wait for the vacation photos! [sighist]
|
|
|
|
|
Thanks to both of you for your posts.. I had a feeling that the thread was exiting before the string could be accessed by my main app.. I went with the easier solution posted below..
Thanks again,
Rob
|
|
|
|
|
You're welcome. Just make sure that you don't post the message to multiple windows, or else the object will be deleted before the second window processes the message
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
I have a simple SDI MFC application.
When I click on the view I show popup menu.
In the OnDraw function of my view I draw some things and I want to know,
if the popup menu is shown, because I want to mark the point where I clicked with
the mouse to open the popup menu!
I want to do like something:
...
if (???->???())
{
... draw a point ...
}
So, how can I check if the popup menu is shown????
Here the code I use to show the popup menu:
CMenu menu;
menu.LoadMenu(IDR_POPUPS);
menu.GetSubMenu(1)->TrackPopupMenu(TPM_LEFTALIGN | TPM_VERTICAL | TPM_NONOTIFY,
pInfo->ptAction.x, pInfo->ptAction.y, this);
Daniel
---------------------------
Never change a running system!
|
|
|
|