|
Interesting question, I'm not sure but I guess the DLL Entry point may be called with DLL_ATTACH_THREAD first which will make it difficult to use your thread creation parameter. I suggest you use the C Runtime thread spawning commands documented here[^] and include the C Runtime source in the include directories of your project. Then you can debug the thread startup process and see if there's somewhere you can attached your control object. You may be able to access your thread parameter through the C Runtime before your thread start function is called.
The alternative is to use structures shared between threads, set up the data for the new thread in this structure (list, array or whatever ) before you launch the thread and use synchronisation objects to safely access the shared data from your secondary thread. This kind of arrangement would probably require a singleton thread factory to ensure that only one thread is created and handed off its data at a time. I have seen arrangements like this working in the past in distributed applications.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
And If I have quad core CPU it makes hairer as I need another levle of syncronazation
Thnakx
|
|
|
|
|
I work on some software which needs to be low CPU usage and high performance.. But I find it hard and annoying to use perfmon to find what I need.
I was wondering what tools people use for profiling their applications?
I'd love to find something like "Super Perfmon". Something that let's me watch things, add events to the record, record system events, reporting, etc...
Any clues for some must-have debug tools?
P.S. I heart Process Explorer!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
I found one article in the website "optimization your worst enemy", take a look, at the bottom are links to other related articles, they maybe help you.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
We use VTune from Intel - works great.
|
|
|
|
|
Hey all,
I encountered this information in a definiton of some function's prototype in C++
<br />
<br />
Library Link to: Ws2_32.lib.<br />
<br />
DLL Requires: Ws2_32.dll. <br />
<br />
Can anyone explain me what does this mean, and how can I link to specified file above ?
|
|
|
|
|
That means the function is implemented in ws2_32.dll and the link library your
project needs to link to is ws2_32.lib.
One way to link to ws2_32.lib is to add ws2_32.lib to the Project/Properties/Linker/Input/Additional Dependencies list.
Another way is to use #pragma comment in the source code, something like
#pragma comment(lib, "ws2_32.lib")
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
I don't know anythign about C++ or classes. All I know is there's a strContent variable sitting in this:
LRESULT CMemMapCppClientDlg::OnDataReady(WPARAM, LPARAM) <br />
{<br />
HANDLE hMapFile = NULL;<br />
PVOID pView = NULL;<br />
<br />
hMapFile = OpenFileMapping(FILE_MAP_READ, FALSE, m_pszMemMapFileName);<br />
if(hMapFile == NULL) {<br />
MessageBox("Can not open file mapping");<br />
return 0;<br />
}<br />
<br />
pView = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);<br />
if(pView == NULL) {<br />
MessageBox("Can map view of file");<br />
CloseHandle(hMapFile);<br />
return 0;<br />
}<br />
<br />
LPSTR szContent = reinterpret_cast<LPSTR>(pView);<br />
int nLen = strlen(szContent);<br />
CString strContent;<br />
while(nLen > 0) {<br />
strContent += *szContent++;<br />
--nLen;<br />
}<br />
strContent += '\0';<br />
strContent.Replace("\n", "\r\n");<br />
MessageBox(strContent);<br />
<br />
if(pView) UnmapViewOfFile(pView);<br />
if(hMapFile) CloseHandle(hMapFile);<br />
<br />
return 0;<br />
} ...which I need to get to from another area of the program.
(The snip is from a Memory Map sample app download from Code Project.)
Is there anybody that can show me how to make some kind of a call (from another class in another module) to this class to get at the value of strContent? Does strContent first need to somehow be teased out of ::onDataReady and placed in its own small function in order to make it available to be called from a separate part of the program.
Thank you if anyone can help.
|
|
|
|
|
e40s wrote: }...which I need to get to from another area of the program.
Not possible since it is local to the OnDataReady() method. Can you make it a class member variable instead?
"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
|
|
|
|
|
|
does the term "class" means something to you ?
|
|
|
|
|
toxcct wrote: does the term "class" means something to you ?
Is that what you go to for learning about stuff?
"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
|
|
|
|
|
sorry, i've been too rude, i appologize Ô sir.
i should have started with "how to define the main() function"
|
|
|
|
|
toxcct, why don't you take a vacation.
>> Not possible since it is local to the OnDataReady() method.
Extremely informative! Thanks!!
>>Can you make it a class member variable instead?
David, if you or others can explain to me the proper way to do this, I would be grateful. Will it mostly be defined through the header file of this source module? (Also are class member variables ordinarily prefixed with "m_"?)
Thanks for any help.
-- modified at 10:37 Thursday 8th November, 2007
|
|
|
|
|
hum, well, i will consider this not to be a personal attack against me, but just a lack of knowledge and maturity about C++.
so, to puch you on the right way, you should start here[^] (we should all );
then, here is what i can say to you :
e40s wrote: >> Not possible since it is local to the OnDataReady() method.
Extremely informative! Thanks!!
well, if you don't know what local means, it's going to be hard for us to explain more, and hard for you to understand more. it part of the basics of many simple programming languages, which basics C and C++ are based upon.
a variable is local to the scope it's been defined within. if you define a variable inside a function, you will be able to access it from within the function, not from outside (outside can mean "from the caller").
if you don't understand this concept, you should first take a book about the programming language of your choice and read the control structures paragraph.
e40s wrote: >>Can you make it a class member variable instead?
David's reflexion makes perfect sense to me.
e40s wrote: David, if you or others can explain to me the proper way to do this, I would be grateful
as i said, his sentence made sense, so the problem is not that we don't explain the proper way, but that you don't understand it...
e40s wrote: Will it mostly be defined through the header file of this source module?
not quite. if it's a member of the class, it's defined inside the class, no matter which file the class is defined on.
e40s wrote: Also are class member variables ordinarily prefixed with "m_"?
that's it, but that's just naming conventions, nothing/noone obliges you to stick to such variable namings...
any more questions ?
|
|
|
|
|
>> so, to puch you on the right way, you should start here[^] (we should all );
then, here is what i can say to you :
You've proven yourself so unworthy of speaking with, and so insecure about your abilities and yourself in general (what kind of ass sneers at questions?), that I wouldn't consider following your links.
>> well, if you don't know what local means, it's going to be hard for us to explain more
I said I don't know C++. It doesn't mean I don't know what "local" means. It means I don't know the language well enough to inter-navigate into and out of localities properly, the way a seasoned C++ programmer would teach. It's why I posted the question.
>> David's reflexion makes perfect sense to me
David's reflection makes perfect sense to me too. But I wanted it matched up with language. (Concepts and their formal language implementation are two separate things.) Learn how to spell.
>> not quite. if it's a member of the class, it's defined inside the class, no matter which file the class is defined on.
The first semi-helpful answer you've provided. But which class? You're not much of a teacher either.
>> that's it, but that's just naming conventions, nothing/noone obliges you to stick to such variable namings
Re the latter, I know that much, but the question really pertained to naming conventions. Thanks.
|
|
|
|
|
e40s wrote: You've proven yourself so unworthy of speaking with, and so insecure about your abilities and yourself in general (what kind of ass sneers at questions?), that I wouldn't consider following your links.
and you think being a member of a forum for 2 weeks gave you more value here ?
wee should all be respecting the forum posting guidelines, and you too !
beeing a newbe here doesn't give you the rignt to ask anything on any ways...
e40s wrote: I said I don't know C++.
well, on swear, i missed that one
e40s wrote: It doesn't mean I don't know what "local" means
your answer to David (another major member which should be respected, far better than I could expect for me)'s post made me think you didn't, sorry.
e40s wrote: The first semi-helpful answer you've provided
i do my best with the few informations you provided from your side too
e40s wrote: But which class? You're not much of a teacher either
man, YOUR class !!! i don't know what class you were talking about, but you were talking about a class, so i meant THAT class.
what can a teacher teach to a student that doesn't want to understand ?
e40s wrote: Thanks
at least a nice word from your mouth too
well, it seems BadKarma gave you some code on another post that seems to satisfy you, happy for you.
for my part, know that I am here to help, but it's not really fair to think that asking somewhat rudely will bring you working code that you only have to incorporate in your code.
this been said,
Welcome on Codeproject, and have a nice end of day
|
|
|
|
|
>> asking somewhat rudely
Where? I really try not to be rude when asking a question.
>> only have to incorporate in your code
This betrays so much ignorance about how people learn, I don't know where to begin. I'll start buy mentioning a little concept of the nature of textbooks called "Examples." People don't learn by parable alone.
In fact, I don't even know why they post sample code to Code Project. People should be able to learn C++ class architecture and its associated language syntax by just having the sample described to them in metaphor, like the way you learned it. You're that talented.
-- modified at 12:21 Thursday 8th November, 2007
|
|
|
|
|
e40s wrote: Where? I really try not to be rude when asking a question.
here[^] ?
so it seems that we both had a defective perception of each other anyway...
let's forget it
e40s wrote: You're that talented
I know :->
|
|
|
|
|
>> so it seems that we both had a defective perception of each other anyway...
The larger point: You shouldn't be abusive to anybody.
|
|
|
|
|
e40s wrote: The larger point: You shouldn't be abusive to anybody
what i thought when i read you : You shouldn't have replied to Mr. DavidCrow like that either
|
|
|
|
|
Again, I ask you where? "How?"
What about "How?", other than its conciseness, offends you?
Nothing at all tense was exchanged beforehand in the conversation to contextually read terseness, and hence rudeness, into it. Frustration, however, can be read into it. (Thanks could easily be assumed among most readers.) People who don't derive joy from offending posters out of a sense of insecurity wouldn't read what you read into it.
Although I did pause considerably before posting that as one word. I had wanted to preface it beforehand with what I always try to preface anything with: "Thank you very much for replying to my post." But as I had still only intended to post "How?" in trailing, I chose the route of informality.
What is it about toxcct that wants to not only assume the worst about his fellow man, but to insult them too? If toxcct learns in milieu, it's an example, but if others do it's only having something they can stick in their own code. If somebody asks about one thing, he doesn't know main(). Stuff like that. I think David was also wondering why you mistreat the poster that way.
|
|
|
|
|
Hi,
add a string member to your class 'CMemMapCppClientDlg'
in header file
class CMemMapCppClientDlg
{
...
protected:
CString m_strContent;
public:
CString GetContent();
};
in the source file
LRESULT CMemMapCppClientDlg::OnDataReady(WPARAM, LPARAM)
{
HANDLE hMapFile = NULL;
PVOID pView = NULL;
hMapFile = OpenFileMapping(FILE_MAP_READ, FALSE, m_pszMemMapFileName);
if(hMapFile == NULL) {
MessageBox("Can not open file mapping");
return 0;
}
pView = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
if(pView == NULL) {
MessageBox("Can map view of file");
CloseHandle(hMapFile);
return 0;
}
LPSTR szContent = reinterpret_cast(pView);
int nLen = strlen(szContent);
while(nLen > 0) {
m_strContent += *szContent++;
--nLen;
}
m_strContent += '\0';
m_strContent.Replace("\n", "\r\n");
MessageBox(m_strContent);
if(pView) UnmapViewOfFile(pView);
if(hMapFile) CloseHandle(hMapFile);
return 0;
}
CString CMemMapCppClientDlg::GetContent()
{
return m_strContent;
}
Now you can use the GetContent function to get the content
{
...
CMemMapCppClientDlg dlg;
...
CString strContent = dlg.GetContent();
...
}
codito ergo sum
|
|
|
|
|
Thank you BK.
Perfect answer. Extremely helpful.
I'll try this in my project and hope it works.
|
|
|
|
|