|
Yes it is. The CS will mean that only one thread can use the resource guarded by it. However, if the data structure is anything but an atomic data type there is the possibility of reading an incomplete (ie corrupt) update.
One way many applications avoid this is by having a queue of allocated changes. The writer gets the CS, allocs a change item, and appends to the queue, releases the CS, then signals a reader (shouldn't normally be more than one).
Reader gets the CS, pulls the queued item, and releases the CS. Uses the queued item to update a snapshot of the data, and deallocs the item. It then calls updateallviews (in MFC apps)
In your design, you are ensuring that the writing of data is serialised; in most cases, reading needs to be the same. I have seen a number of instances where all iterating over a collection needed to be guarded by a sync object as did all writes/erases; the original developer didn't understand that the collection was not thread safe in the sense that modifying while reading was a bad thing to do.
Steve S
Developer for hire
|
|
|
|
|
Hi,
My messagebox code snippet is like this
MessageBox( "Welcome", "title",MB_OK|MB_ICONINFORMATION);
How do i control the location of the message "welcome" in the messagebox? (if i want to move the word "welcome" to someother place, how do i do tat?). Can anyone please help me in this problem?
Thanks in Advance.
Regards,
Ram
|
|
|
|
|
Ram Murali wrote: ow do i control the location of the message "welcome" in the messagebox? (if i want to move the word "welcome" to someother place, how do i do tat?). Can anyone please help me in this problem?
use \n :- New Line
\t :- tab!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I wannu control the location of the string in -x direction(move towards left side) not in y direction. sorry for the confusion.
Regards,
Ram
-- modified at 3:32 Friday 21st July, 2006
|
|
|
|
|
Ram Murali wrote: wannu control the location of the string in -x direction(move towards left side) not in y direction. sorry for the confusion.
For that you have to write your own custom MessageBox as quoted by NiceNaidu
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Re
|
|
|
|
|
|
How can i convert a value that is in char format: char news[16] to string? the simple sintax:
CString str2 = news;
str2.Format("%s");
doesn't seem to do it.
|
|
|
|
|
CString str2;
str2.Format("%s",news);
Will do this.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
y such a long link for this?????/
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Keeping view of Beginners, I posted that.Itz really good link for Beginners.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Its me wrote: y such a long link for this?????/
just a normal habit of programmer.... cut and paste
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
tanarnelinistit wrote: CString str2 = news;
str2.Format("%s");
this will do too, call argument constructor of CString class
CString str2(news);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Dear all,
I placed a picture control on the Dialog window.Above that picture control I have placed the button control .
But buttons are not visible when the application starts ,I have to click in the place where i have placed the button to make it visible.
How to make the button visible at the time of appication starts?
Manjunath S
GESL
Bangalore
|
|
|
|
|
Check whther the PictureControl is covering the Button Control .
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Hi,
Its covering the button control .....Is there any way to solve it...
Manjunath S
GESL
Bangalore
|
|
|
|
|
Place the button outside the PictureControl region
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Hi,
can we give color to a portion of the dialogbox ...
Manjunath S
GESL
Bangalore
|
|
|
|
|
Only to a portion or to whole dialog????
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
U can paint to a portion of the dialog in OnPaint()
try this one
<br />
CPaintDC dc(this);<br />
CBrush myBrush;<br />
myBrush.CreateSolidBrush( RGB( 250, 200, 0 ));<br />
dc.SelectObject( &myBrush );<br />
dc.Rectangle( 0, 0, 40, 40 );<br />
myBrush.DeleteObject();<br />
CDialog::OnPaint();<br />
To whole dialog use OnCtlColor
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
wat a good answer
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Its mewat a good answer
Thanks.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Manjunath S wrote: placed a picture control on the Dialog window.Above that picture control I have placed the button control .
But buttons are not visible when the application starts ,I have to click in the place where i have placed the button to make it visible.
change control ORDER.. by pressing CTRL +D in Dialog Editor!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
whenever i open a new project in vc++ nad tryt to run without any modification it ha error
:\myproject\location\cntritem.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/location.pch': No such file or directory
Error executing cl.exe.
an u help me?????????how to solve
|
|
|
|
|
I think you need to turn back on the "using pre-compiled header" option, that someone had you disable a few messages back.
- S
50 cups of coffee and you know it's on!
|
|
|
|