|
Hi,
it seems to me, that you have some weird problem with thread synchronization somewhere. By changing the optimalization switch, the compiler changed the order/amount of instructions that can changed the order/timing of some operation.
This can lead to the situation, where with speed optimalization the thread initialization finishes before other thread uses it, but with optimalization off the initialization is not finished yet, so the second thread uses something uninitialized.
By introducing the Sleep(0) you changed the order of the instructions stream, so it could 'fix' your issue at the moment. But if the synchronization problem is in your application, it will pop-up somewhere else, so definitielly Sleep(0) is not a conceptual solution for such a problem.
By using the event synchronization, you can fix the problem usually (or a part of it). But from the description you gave, it seems that effectivelly you only introduced the 500ms sleep to the start of the application, so just postponing the problem. Only idea I can get is that either the event is not signalled at all, or you can use two different handles, not the same event for synchronization.
hope this helps, dont't hesitate to ask for more
|
|
|
|
|
My C++ application makes system calls, that use cmd.exe ( net use, copy, run .exe, getmac ) with parameters. I am writing a wrapper function that will handle all the parameter formatting, waiting for command to complete, and check the return values.
At first I used the system() command, but I want to hide the cmd window.
So I tried WinExec(), but this runs as a seperate thread and i do see how to suspend the parent thread.
So I tried CreateProcess() but I my exe could be running on any windows platform including Win 95/98. CreateProcess has some compatiblity issues with these version and hiding the window, from what i have read. I am guessing i would have the same problem waiting for the command to complete anyways.
So I tried ShellExecute() but again I was unable to get the parent thread to wait for the command to terminate.
So now I am working with ShellExecuteEx() but again i am having trouble getting the parent thread to wait until the command ends.
can show me how to wait for WinExec, ShellExecute, ShellExecuteEx to finish?
I've been working with WaitForSingleObject but i am missing something..b/c i cannot get it to work.
|
|
|
|
|
jet915 wrote:
My C++ application makes system calls, that use cmd.exe ( net use, copy, run .exe, getmac )
Why use this antiquated approach when functions exist for just such purposes?
jet915 wrote:
So I tried CreateProcess() but I my exe could be running on any windows platform including Win 95/98. CreateProcess has some compatiblity issues with these version and hiding the window, from what i have read.
It works on Windows 95 according to MSDN. What specifically did you read?
jet915 wrote:
So I tried ShellExecute() but again I was unable to get the parent thread to wait for the command to terminate.
It's part of the PROCESS_INFORMATION structure.
jet915 wrote:
can show me how to wait...
PROCESS_INFORMATION pi;
...
CreateProcess(..., &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
hi, I download the windbg and tried to use to debug my code.
but how to attach the project with the windbg? seems like VS and windbg is running seperate, does anybody has step by step documentation? thank you!
I can't find any moeory.dum file in my machine.
|
|
|
|
|
Check out Toby Opferman's article(s).
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thanks for reply. I am looking for the memory dump file in my machine, but no luck so far, wondering if the windows2000 could not generate such file....?
thank you for any info!
|
|
|
|
|
If a control has tabstop set to true then it can also be accessed with the mnemonic access keys. I have a control that has tabstop set to false (don't want user to be able to tab to it) but do want to allow access via the access key. I've noticed that it doesn't work when tabstop set to false. I've even tried setting a static control with tab order preceding the control to help get the caret there but no luck. Would I have to intercept a windows message to do this? Saw in Spy++ some GetDlgCode messages being fired during the Access Key event but not sure what to do. Thanks
|
|
|
|
|
mx483 wrote:
...the access key.
Do you mean mnemonic?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Yep mnemonic. I even tried an accelerator key that was mapped to code that would set the focus but I haven't gotten that to work either. Back to the drawing board.
|
|
|
|
|
Was successful in mapping an accelerator key to some code that put the focus to a control that had tabstop set to false. It wasn't working originally because I was using a dialog app that probably didn't have the accelerator table attached. Curious if there are other solutions. This seems to work pretty well though.
|
|
|
|
|
i dont see menu on this code . can some1 help me . how can i view a pop-up menu programaticaly
m_menu.m_hMenu = NULL;
m_menu.CreatePopupMenu();
CMenu childmenu;
VERIFY(childmenu.CreatePopupMenu());
m_menu.AppendMenu(MF_STRING | MF_POPUP | MF_ENABLED, (UINT)childmenu.m_hMenu, _T("&Delete"));
childmenu.Detach();
childmenu.DestroyMenu();
///BOOL res1 = m_menu.EnableMenuItem((UINT)childmenu.m_hMenu, MF_ENABLED);
BOOL res2 = SetMenu(&m_menu);
///this->DrawMenuBar();
|
|
|
|
|
I don't really see what you want to do but if you want to show a pop-up menu, you will need to call TrackPopupMenu member function from CMenu.
|
|
|
|
|
|
i'm pushing values inside a vector using push_back()...
then.. to print it can't we use cout< >::*)(void) const'
Error executing cl.exe.
Thanx
V
|
|
|
|
|
That would help a lot if you were using the < tag that is just above the emoticons (your code is impossible to read, and the same for the error message). And also, put the declaration of the vector itself.
|
|
|
|
|
#include <vector>
using namespace std
{
vector<int> vec;
vec.push_back(1);
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);
for(int i=1;i<vec.size;i++)
cout << vec[i];
}
thanks,
V
|
|
|
|
|
The problem is not on cout, the problem is at this line:
Vivekuniq wrote:
for(int i=1;i<vec.size;i++)
You forgot the parenthesis after size. Try this instead:
for(int i=1;i<vec.size();i++)<br />
|
|
|
|
|
It seems that you are trying to write the data where you should evalute the lopp condition ... but if you could write the whole piece of code would be quite more understandable ...
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
marcdev wrote:
It seems that you are trying to write the data where you should evalute the lopp condition
No, it's just because the '<' symbol is interpreted as an HTML tag so a part of his code has been removed.
|
|
|
|
|
Ok, i didn't realise about that !!!
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
|
#include <vector>
using namespace std
{
vector<int> vec;
vec.push_back(1);
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);
for(int i=1;i<vec.size;i++)
cout << vec[i];
}
Thanx
V
|
|
|
|
|
sh*t, this is silly . sorry guys...
Thanks a lot
V
|
|
|
|
|
Stupid STL trick:
std::copy(vec.begin(), vec.end(), std::ostream_iterator<int,char>(std::cout," "));
|
|
|
|