|
Environment.NewLine
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
this.label1.Text="line 1"+Convert.ToChar(10)+Convert.ToChar(13)+"Line 2";
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
It's not clear to me how I am expected to use Queue Synchronization.
Is this a general state, which makes the Queue thread safe? Or is this a short, temporary measure I use to lock the queue before I read or write it, and immediately release it when I'm done?
The documentation and samples are too short and don't go into detail on this.
So my question is: do I simply wrap my Queue with a synchronized wrapper and leave it on, doing all further access through that wrapper?
Or do I only wrap the Queue when I'm accessing it, and immediately drop the wrapper when I'm done?
Do I pass the wrapper to other objects, or only the original Queue?
Thanks for any help here.
|
|
|
|
|
Once you call Synchronized(), you should use the returned wrapper
everywhere you would have used the original unsynchronized queue.
Use of the queue through the wrapper will be thread safe for all
"single operation" methods on the queue.
Make sure Synchronized() is really what you need for a thread safe queue.
Enumerating and indexing the queue aren't going to be thread safe
so you may need additional locks.
Making your own thread safe wrapper (or derived) queue class can
be better in some situations. It allows you to implement locks
the way you need to (like using a ReaderWriterLockSlim for producer/consumer
thread access) and provide properly locked enumerating methods.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the response. Okay, so the Sync wrapper persistently replaces the Q itself, and it is the object I should pass around between methods, etc. That was not entirely clear to me before.
This should probably work for what I'm doing; I spawn a listener object on a new thread, which listens for events from a COM object. My main thread passes various Queues to the spawned object (actually, sets them as properties), and the spawned object, when it receives messages, puts a notation in the queue(s).
My main thread polls the queue, dequeuing any notations it finds.
So there's no enumerating or indexing, I think. Of course, I haven't written it yet...
|
|
|
|
|
Multiple writer threads and a single reader thread, right?
The Synchronized() queue should indeed be fine for that.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I have a navigation board(ToolStrip object) above a DataGridView object
I use this code to get data from it.
ToolStripTextBox_Row.Text = DataGridView_Country[0, grid_index].Value.ToString();
Ok, now i want to press Button_NextRow (in navigation board) and
set focus to next row in the DataGridView.
How can i do this?
|
|
|
|
|
It is currently displaying the stack upside down, the contents of the top of the stack are displayed as the last line in the text box. I am trying to make this code display the contents of the stack at the top of the text box.
private void displayStack()
{
string nextItem;
displayBox.Clear();
for (int i = 0; i <= stackTop; i++)
{
nextItem = stackArray[i].ToString();
displayBox.AppendText(nextItem);
displayBox.AppendText("\n");
}
}
|
|
|
|
|
Just loop the other way.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
How do I do that?
|
|
|
|
|
private void displayStack()
{
string nextItem;
displayBox.Clear();
// doing it the other way like guffa said
for (int i = stacktop; i >= 0; i--)
{
nextItem = stackArray[i].ToString();
displayBox.AppendText(nextItem);
displayBox.AppendText("\n");
}
}
instead of starting from bottom value of your stack,(originally your intial conditon is int i = 0) you are now starting at the max value of your stack.
Instead of stopping the loop when your variable "i" reaches "stacktop" (top of your stack), the loop stopped at "i = 0"(bottom of your stack).
Because of the above 2 statements, i++ have to change to i-- since you are starting from top to bottom now.
|
|
|
|
|
Thank you Lim and Guffa.It is now working exactly that way. Thank you so much!!!
|
|
|
|
|
Hi Friends
I got a task from my team lead to create a desktop news ticker.
If any one have code or else an helpfull link for the same, please reply back. Thanks in advance.
|
|
|
|
|
|
You need to fix the sign-up. Not working
|
|
|
|
|
What have you done so far, idea-wise?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I am doing research on it, I have not yet started writing code.
What actually I need is a scrolling text on my desktop which must not be a usual text but link and when any of the link is clicked, it should navigate to that particular page
|
|
|
|
|
I recall seeing a Marquee type of control in an article here on CP. I imagine if you can find it, you could create a custom control to have the text be a linkable hypertext. If one doesn't already exist here, it would be a cool article idea.
http://www.codeproject.com/KB/miscctrl/csmarquee.aspx[^] is one I found. Bet it could be customized for your purposes.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Thanks a lot paul. I will check it.
|
|
|
|
|
I was looking for something like that too, i going to check it out.
|
|
|
|
|
I am developing a major application that (among other things) talks to SQL Server databases. I have it built with a platform target of "Any CPU".
However, it has to be able to import legacy data from mdb databases. The Jet database engine is only available on the 32-bit platform. I have created a .NET assembly built with a platform target of "x86" for the main application to call to do the importing.
The problem is that I get a BadImageFormatException (0x8007000b) when trying to load the dll when running 64-bit Vista. There seems to be a division of opinion about whether the 64-bit framework should be able to load 32-bit dlls.
Does anyone have a definitive answer, or a solution to the problem? I really don't want to have to build the whole app to target 32-bit just for the sake of the mdb importing functions.
[update]
The 32-bit assembly also needs to be able to call into some of the other 64-bit assemblies. Maybe this is a killer anyway?
[/update]
Thanks in advance.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
modified on Friday, August 1, 2008 11:35 AM
|
|
|
|
|
On a 64-bit x64 machine:
anycpu.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll
x86.exe -- runs as a 32-bit process, can load anycpu.dll and x86.dll, will get BadImageFormatException if it tries to load x64.dll
x64.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll
Ref:-
http://blogs.msdn.com/joshwil/archive/2005/04/08/406567.aspx[^]
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
Thanks for the link.
I've seen another blogger contradict that but I think my experience shows that the guy you link to is the one who's right.
I suppose I'll just have to drag everything down to x86 . Maybe one day I'll write a separate app to do the conversion.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
In one of my project's , I remember we had two saperate build
one for 64-bit & one for 32-bit machine < although i dont like it >
We had to get/beg all 3-rd party dll to be 64-bit.
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
I'm trying to set a combo box on the forum to the corresponding item I'm passing it through the constructor, but it just ignores the value I'm passing it, and displays the first item in the combo box item collection. That data I'm trying to pass is taken from a deserialized XML file. Please let me know if there's anything else I need to provide you with for help Thanks.
this is how I'm binding the combo box's, in the designer.
this.cmbResults.DataSource = System.Enum.GetValues(typeof(PickItResult));
this.cmbQuality.DataSource = System.Enum.GetValues(typeof(D2Data.ItemQuality));
this.cmbItemType.DataSource = System.Enum.GetValues(typeof(D2Data.ItemType));
this.cmbItemClass.DataSource = System.Enum.GetValues(typeof(D2Data.ItemClass));
'the constructor I'm trying to set the combo box item in, i've tried many different things
public Requirements(string description, string mods, D2Data.ItemQuality quality, D2Data.ItemType type, D2Data.ItemClass itemClass, string stats, PickItResult result)
{
InitializeComponent();
this.description = description;
this.mods = mods;
this.quality = quality;
this.type = type;
this.itemClass = itemClass;
this.result = result;
this.stats = stats;
txtDescription.Text = description;
cmbResults.SelectedItem = Enum.Parse(typeof(PickItResult), result.ToString());
cmbQuality.SelectedItem = Enum.Parse(typeof(D2Data.ItemQuality), quality.ToString());
txtMods.Text = mods;
txtStats.Text = stats;
}
|
|
|
|