|
You probably have code looking like this in your thread:
while( !m_bStopPushThread )
{
}
Chances are that the m_bStopPushThread has been optimized into a register in your thread controlling loop which means that the thread won't see the value change.
This happens if the variable is not written to inside the loop.
Building a debug version disguises this behaviour since optimizations usually are turned off.
The remedy is to declare the variable m_bStopPushThread as volatile , which will tell the compiler to read its value from the variables memory address every time and not to hold its value in a register.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
If I had to guess, as someone already stated, g_hThreadHandlePush may not be the actual thread handle that you're expecting. To follow up on that, I hate to see people wait on something for an INFINITE time span. I know some disagree, but imagine if someone works on your code years later when you're not around and removes (for example) the m_bStopPushThread variable... they would end up with a freeze and it would be very hard to pinpoint where the freeze is occurring (debugging in multithreaded applications gets complex). I think you're better off setting a reasonable timeout, then alerting as to what occurred (using trace statements, message box, whatever).
|
|
|
|
|
Hi,
I am using CRichEditCtrl. I need to add percentage in a loop at end of text.
Every time I need to call GetWindowText() and append text and again SetWindowText(), but due to this I am getting flickring.
How can I add only a single line og text in CRichEditCtrl so that I can avoid flickring.
|
|
|
|
|
|
|
Don't know how much it would flicker, but try using CRichEditCtrl::SetSel[^] and CRichEditCtrl::ReplaceSel[^] to change only the part of the text you want. You might try combining it with CWnd::SetRedraw[^] and CWnd::RedrawWindow[^] to have it redraw itself only once after the text has been changed.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
|
I am new to the MS TR1 2008 implementation of regex.
My application used to use a regex provided by a third party sofware house (Tropic Sofware East) - but I decided to move to MS TR1 version (from all the reports I read - I am beginning to regret that decision).
Has any one else experienced problems with matching reg-expressions that are case sensitive? Here is an example:
...
fOption |= std::tr1::regex::icase; // Ensure case-insensitive.
...
try
{
a_pRegex->assign( a_pszString, fOption );
}
...
// later
std::string str = ( LPCTSTR )szString;
if( regex_match( str.begin(), str.end(), *m_pRegex ) )
{
// Yippie .. a match
...
}
It's not important about the variable names that get passed around in the code (as the snippet is obviously heavily edited. It nevertheless does not perform a match - even on a simple 'HELLO' and 'H[a-z]+O') - if anyone has any pointers as to where I am going wrong - I'd appreciate the help.
Regards.
James
|
|
|
|
|
TenFiftyTwo wrote: It nevertheless does not perform a match - even on a simple 'HELLO' and 'H[a-z]+O')
I've not ever used that library, but what about:
H[A-Z]+O
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
As I read the question, the OP isn't looking for an uppercase regex; he wants case-insensitive matching.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Hi.
Yes, that works, the problem seems to lie in that the chars between the brackets [] do not get processed in a case-insensitive way.
I believe the following describes the problem:
www.comeaucomputing.com/iso/lwg-active.html#523
It is still flagged as an open issue - if this is actually the case then this is madness. The least I expect from a regex, is to be able to perform a case-insensitive comparison on a given range of characters.
-- modified 28-Sep-11 5:42am.
|
|
|
|
|
TenFiftyTwo wrote: Yes, that works, the problem seems to lie in that the chars between the brackets [] do not get processed in a case-insensitive way.
So then how about:
H[A-Za-z]+O
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi.
Thanks very much - thats what I did in the end. I know the example I gave was trival and the real expression is significally more complicated; so I wanted the fastest regex I could get. The process operates on potentially many miliions of lines of data and I wanted to keep the process as 'inexpensive' as possible.
Neverthless - thanks a lot for your time and effort pondering this.
Many thanks.
James.
|
|
|
|
|
Obvious dumb debug thing I'd do - dump the arguments you're actually using immediately before the regex_match() call. You use a_pRegex in one place and m_pRegex in another, so I, for one, don't know what is actually going to be used...
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I want to build a parameters string, but keep each parameter on it's own line for easy editing and reading.
The variable is a CString, and I want to make 1 giant string out of it. Just looking for the proper way to do this.
lp_Parameters = "/iu " +
"IIS-WebServerRole;" +
"IIS-WebServer;" +
"IIS-CommonHttpFeatures;" +
"IIS-StaticContent;" +
"IIS-DefaultDocument;" +
"IIS-DirectoryBrowsing;" +
"IIS-HttpErrors";
|
|
|
|
|
get rid of the + operator.
so
CString string("/iu "
"IIS-WebServerRole;"
"IIS-WebServer;"
"IIS-CommonHttpFeatures;"
"IIS-StaticContent;"
"IIS-DefaultDocument;"
"IIS-DirectoryBrowsing;"
"IIS-HttpErrors");
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
|
Adding strings together and CString.Format() do give the same results. However, for some uses, like if the string is periodically edited, adding strings is easier to change / expand / delete things without having to go back and fix the formatting control string too. Especially when mixing constant strings and variables to create a MessageBox string.
|
|
|
|
|
except that he's not formatting a string, there are no parameters. Otherwise I would agree.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
You can still use the method... it should save operating cycles over putting a bunch of strings together, since it won't call individual constructors.
|
|
|
|
|
true, it saves over using the + operator, but since the ctor is going to be called anyway, you're calling an extra method (Format) unnecessarily.
As, I'm sure you know, the compiler does the concatenation of adjacent strings ("abc" "def") is the same as ("abcdef"). So simply removing the + operator and explicitly calling the ctor is better.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
No need for the + signs, this should work (as long as there is nothing else between the "string fragments":
lp_Parameters = "/iu "
"IIS-WebServerRole;"
"IIS-WebServer;"
"IIS-CommonHttpFeatures;"
"IIS-StaticContent;"
"IIS-DefaultDocument;"
"IIS-DirectoryBrowsing;"
"IIS-HttpErrors";
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Hummm, learn something new everyday. For a language that says that whitespace doesn't matter, here it does and it appears to permit concatenation of adjacent strings.
Forgive me but I find putting in the explicit + more clearly states my intentions.
|
|
|
|
|
except that the explicit + operator causes code to be called for each +. A ctor and the operator+() method.
the other way, only one method gets called - the ctor or the assignment operator.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Oh, I agree that there are runtime performance considerations of adding strings at runtime versus letting the compiler do it at compile time.
If this were in a critical path for performance, I would say do it your way. I often will trade of these small performance considerations for clarity / readability of the code if it occurs in a once-only or non-critical path, like error messages or response to a user triggered event (pushes a button).
|
|
|
|