|
You need atoi instead of itoa.
|
|
|
|
|
Hi,
I have a class which will be accessed by two or more threads and I wondered if what I have done is OK or if there is a better way. I have added a CCriticalSection class member which is initialised in the constructor. Then, each class method uses EnterCriticalSection and LeaveCriticalSection.
The problem is that there are 100 instances of this class and I wondered if having so many critical sections was a burden on the operating system. I thought of having a single CCriticalSection static class member but (rightly or wrongly) I figured that I would be unnecessaryly locking access to all instances and could end up with the code being locked most of the time.
I would really appreciate youe views on this. I understand the basics of multithreading but its still a bit of a mystery.
TIA
Tony
|
|
|
|
|
It sounds like you have it right to me.
Using one critical section for all instances could definitely impact performance with only
one thread able to access any object at one time. It's still a viable solution but only if
that's really what you want or need.
I would imagine the only burden on the system is more memory/handles being used for each sync
object. 100 is relatively few. The class instances have to be thread protected so there's not
much choice anyway
I thought the OS was THERE for us to burden
Mark
|
|
|
|
|
Hi Mark,
Thanks very much for your reply. The code appears to work well but its good to have someone else give a quick sanity check on what I have done.
Thanks again
Tony
|
|
|
|
|
i am using unicode
when displaying strings from the string table on a message box
AfxMessageBox(IDS_MSG_STRING, ...);
where IDS_MSG_STRING is an entry in the sting table, the following occure:
1- in debug mode: every thing foes nice.
2- in release mode: the message box pops up as usual but displaying the following string "an unnamed file".
why is that and how to avoid it?
thankx in advance
k_dehairy
|
|
|
|
|
If my project work in "Multithread" and during process in every thread will generate message box for ask user what the way user want to do.
How I check in main program, the message box that occur.
Which thread generate it?
|
|
|
|
|
Use the void pointer (LPVOID) which you pass while creating the thread.
<code>
int threadCount;
AfxBeginThread(YouThread,(LPVOID)threadCount);
UNIT YourThread(LPVOID lp)
{
int threadCount = (int)lp;
yourFunction(threadCount);
}
void yourFunction(int threadID)
{
do
{
itoa(threadID,ch,10)
MessageBox(..ch)
}while()
}
</code>
Code-Frog:So if this is Pumpkinhead. Time for him to run and hide. It's an interesting thought really.
|
|
|
|
|
Or the simpler way is you can simple have a GlobalThreadID, that gets incremented everytime you create a thread, and you assign it the local variable that you will have in the thread function.
Code-Frog:So if this is Pumpkinhead. Time for him to run and hide. It's an interesting thought really.
|
|
|
|
|
Guys,
I ran into this issue during migration of project from .net2003 to vs2005.
Have you guys encountered something similar and fixed the same?
error LNK2019: unresolved external symbol "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) referenced in function "public: __thiscall std::bad_alloc::bad_alloc(char const *)" (??0bad_alloc@std@@QAE@PBD@Z)
error LNK2001: unresolved external symbol "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z)
error LNK2001: unresolved external symbol "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z)
SharedMemory.obj : error LNK2001:
Vipin
|
|
|
|
|
|
You find your answer
|
|
|
|
|
I originally using Visual Basic 6.0 and .NET.
But, I realized vb is had limited.
so, I'm turning to VC++/MFC.
I knew VB's The general trend is transition to .NET
but, I don't know in VC++.
Is VC++'s trend 6.0? or trend is .NET?
I wandering this problem.
I really appreciate, If i had your reply.
thanks~
Aim High, life is soaring
but, Aim Low, life is boring!
|
|
|
|
|
Always use the correct tool for the job. Personally, I don't think .Net is appropriate for desktop applications, but if the boss says "Use .Net", guess what I'm going to do. In the end, it's all about keeping your job, and maintaining a marketable skill set. You simply have to learn it all. It's fine to be strong in one particular programming language, but you absolutely MUST be at least conversant in most of them.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
i need your help....
with the script that can connect the contain of textbox after the button event to access database....
please.....
|
|
|
|
|
Do you want to insert a text(of editbox) to a database?
|
|
|
|
|
Can anyone have the idea of calling XFS API in .net (C#).
|
|
|
|
|
I think you selected wrong forum here c++
|
|
|
|
|
Hi,I have met the same confuse like you ? have you found the solution? please give me some help,thank you very much
|
|
|
|
|
hi sir..
i am beginner of MFC.so please tell me a possible way to retrieve the applications running in the remote system...please reply me as soon as possible....
|
|
|
|
|
Do u know how to retrieve the application running on a local computer?
As u r a novice, don't go beyond very advance level, I recommend.
Come online at:-
jubinc@skype
|
|
|
|
|
hi sir...
thanks for ur advice...
but i need to implement it in my project...so please give me a suggestion to find the same..please tell me how to retrieve in the local system too..interested in knowing that also.. please reply me sir...
thanking u..
|
|
|
|
|
Check the sample ProcessViewer from Platform SDK. It does exactly what you need.
And, by the way, "please reply me as soon as possible" won't get you many replys. This time you were lucky, but next time you may get flames. Or get ignored.
Nuclear launch detected
|
|
|
|
|
When the user in my application chooses exit from the menu, hits escape, or presses the X, I want my application to cleanup memory before closing. Usually I just put the cleanup code in the OnClose message handler. From a log file the cleanup generates, the OnClose gets called multiple times and my application crashes during the cleanup, attempting to delete the same memory multiple times.
I've tried hackish solutions that include setting a flag the first time the function is called and just returning the next time, but then the window never closes. There is nothing in my cleanup that would call OnClose() again.
Any ideas on how to approach fixing this? The debugger isn't being terribly useful.
Thanks
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Aaron Stubbendieck wrote: the OnClose gets called multiple times
Have you missing the call of the base class OnClose() in your handler, haven't you?
Aaron Stubbendieck wrote: crashes during the cleanup, attempting to delete the same memory multiple times.
Use the following behaviour when performing cleanup:
if ( pSomeObject )
{
delete pSomeObject;
pSomeObject = NULL;
}
At least, this avoids program crashes due to multiple delete calls.
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.
|
|
|
|
|
Hi
Why you don't put your cleanups in your destructor function?
|
|
|
|