|
You can change the process's priority class with SetPriorityClass(), or the priority for a thread with SetThreadPriority().
|
|
|
|
|
Perspx wrote: Does creating more threads increase the time slice allocated for the process for the CPU?
At the kernel level there is a linked list of executing threads for each priority level. So increasing the number of threads in your application could in theory increase the number of time slices relative to other processes of the same priority. But adding more threads does not always mean better performance as you will also be increasing the number of context switches which are expensive.
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
|
Thank you everybody you have shed some more light on the matter
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
|
What is menat by the fact that windows handles are passed from one thread to another. What does it imply and when is it used? Also why is it that if the wrapping C++ windows objects are passed from one thread to another unexpected results occur.
|
|
|
|
|
Passing a pointer to a CWnd object between threads is not safe since the CWnd object is not created by the other thread(s).
Thread uses local storage to map window handles, therefore object that was passed by a pointer may have (and most certainly do) different handle mapped to it. Use handle of a window attached to the CWnd object instead, and post/send messages using this handle.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am desgning an addition of Visual Studio makefile solution which contains only one project
I figure I'll make my code another project in C++ maybe use .NET (the orignal code/project/solution is C)
The project I am writting contains 3 classes
The first Class is Global as there is only 1 instance
by that I mean it should be able to be accessed by all functions within the project('s) there are locking mechinism to ensure single threading/proper access
I thought about writting this CLass as a DLL
Few questions come to mind
1) can I keep all three class in the same project
2) Should I export and import the entire class e.g.
Class _declspec(dllexport) DllClass
{
and conversely in the program using the DLL
Class _declspec(dllimport) DllClass
{
or maybe only certin methods or data members
3) do I need to decalre all members and methods
as static
4) Do I a LoadLibrary/GetProcAddress ??
if I use the dllexport/dllimport do I still need
to do a LoadLibrary/GetprocAddress call ??
Thankx in advance
|
|
|
|
|
Why multiple inheritance is not corrected by using virtual inheritance of the COject class in MFC. The explanation in MFC is not very clear.
|
|
|
|
|
|
Yes the MSDN tech note looks more of a specification. I would like to know more substantial information. And stuff like when there could be a case when MI has to be used. When I need to derive a class from two classes whose base class is CWnd. Why this scenario is going to fail?
|
|
|
|
|
tom groezer wrote: When I need to derive a class from two classes whose base class is CWnd. Why this scenario is going to fail?
This paragraph sums it up quite nicely:
The CObject::IsKindOf member function will not correctly determine the type of an object if it has multiple base classes. Therefore, you cannot use CObject as a virtual base class, and all calls to CObject member functions such as Serialize and operator new will need to have scope qualifiers so that C++ can disambiguate the appropriate function call. If you do find the need to use MI within MFC, then you should be sure to make the class containing the CObject base class the left-most class in the list of base classes.
By deriving from two CWnd classes, references to CObject member functions will be ambiguous, and will need to be dealt with explicitly.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for that
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi everyone,
I am using an activex control which i have inserted onto a formview of an mdi application.when i press File->new option i get a new window with the activex in it. Now i want to implement the same funtionality on a button press. i want the same results as that of File->New.How do i achieve it from the CFormView or the Cmainframe class.
|
|
|
|
|
Maybe something like this:
if (AfxGetApp()->m_pDocManager)
AfxGetApp()->m_pDocManager->OnFileNew();
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
O' My God that really worked like magic.. But how do i get a pointer to each view. I want to pass data to the view
|
|
|
|
|
I'm glad it worked. That's how MFC does it but it's using an undocumented variable (although
it's worked for as long as I can remember).
You probably could just give your button the id ID_FILE_NEW and it would have worked like magic
too I thought for sure someone here would jump on me for that one LOL.
chaitannya_m wrote: But how do i get a pointer to each view. I want to pass data to the view
Which view? The one just created?
The view just created should be the active view. To get the active view in MDI;
CMDIFrameWnd *pFrame =
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild =
(CMDIChildWnd *) pFrame->GetActiveFrame();
CMyView *pView = (CMyView *) pChild->GetActiveView();
To iterate through all views, one way is to iterate through all documents and their associated
views:
POSITION DocTemplatePos = AfxGetApp()->GetFirstDocTemplatePosition();
while (DocTemplatePos != NULL)
{
CDocTemplate *pTmpl = AfxGetApp()->GetNextDocTemplate(DocTemplatePos);
POSITION DocPos = pTmpl->GetFirstDocPosition();
while (DocPos != NULL)
{
CDocument *pDoc = pTmpl->GetNextDoc(DocPos);
POSITION ViewPos = pDoc->GetFirstViewPosition();
while (ViewPos != NULL)
{
CView *pView = pDoc->GetNextView(ViewPos);
}
}
}
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
What are the best books to start knowing about data structures from a begineer point of view with emphasis on hands on rather than the theoritical aspect? Any help would be highly appreciated.
|
|
|
|
|
|
tom groezer wrote: What are the best books
What's good for others may not be good for you, and vice versa.
What's wrong with this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
I'm trying to use the Replace function of the CString class, and it seems to be mostly fine, except it's ballsing up in one particular instance. I can't see what I'm doind different, but for some reason it doesn't like this:
CString PostCode;
m_PostCode.GetLine(0, PostCode.GetBuffer(m_PostCode.LineLength(0)), m_PostCode.LineLength(0));
PostCode.Replace("'", "''");
where m_PostCode is a member of the class this code is called from, being an instance of CEdit. I can't see anything that I'm doing differently to any other times I'm using the Replace function, but in this instance it just won't replace ' with ''.
Any ideas? I can't seem to find anything that suggests this is a known issue.
Thanks!
Louis.
Addendum:
I've noticed that it occurs with other CString/CEdit pairs like this, but if I copy the contents of the CString into a new CString, then run the Replace function of the new string it works fine. Am I missing something here?
-- modified at 12:05 Wednesday 4th July, 2007
|
|
|
|
|
Maybe try calling
PostCode.ReleaseBuffer(m_PostCode.LineLength(0));
before calling Replace()
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Yes, this worked like a charm!
Thanks a lot Mark, very speedy response!
Louis.
|
|
|
|
|
Hey Guys,
I have an MFC CStatic derived class that has a public member function Draw();. Draw uses GDI to draw stuff to the CStatic window. I call this Draw method from a multimedia timer (timeSetEvent) to continually update the display.
My problems is that When my main app is doing a lot of work the drawing is sometimes interrupted when I load files. So I put the lengthy process of loading files in a worker thread, but the drawing is still "jerky" when loading a file. Is there anything else I can do to ensure that my CStatic is always drawing? Is this something I need a user interface thread for?
Thanks,
Greg
|
|
|
|
|
I'm not certain what you're trying to achieve here as genuinely constant redrawing would preclude you doing anything else anyway but you may have run up against a perenial problem with the MFC architecture. Essentailly anything done to the user interface is done on the main thread even if you call it from a worker thread. I would definitely suggest doing the file loading on a worker thread before getting into the absolute minefield of multiple user interface threads.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|