|
gvanto wrote:Is there some way of using a string array to assign each element as the "name" of a variable?
Well, instead of using a generic List, use
Dictionary<string, Thread> MyThreadsCollection = new Dictionary<string, Thread>();
MyThreadsCollection.Add(ThreadName, MyThread);
Where the ThreadName is the text you get from the RichTextbox.
To get the Thread with the specific name use
MyThreadsCollection[ThreadName] = new Thread(new ThreadProc);//for example
gvanto wrote: Also, is it possible to pass an argument to the ThreadProc method?
Use ParameterizedThreadStart delegate instead of ThreadStart.
Regards
|
|
|
|
|
Wow thanks Nader,
Your methods are excellent and have been VERY helpful thanks a million!!
I'm actually doing it like this:
<br />
<br />
for (int j = 0; j < InList.Length; j++)<br />
{<br />
AddThread(InList[j]); <br />
} <br />
<br />
private void AddThread(string threadName)<br />
{<br />
ThreadStart threadDelegate = new ThreadStart(ThreadProc);<br />
Thread t = new Thread(threadDelegate);<br />
t.Name = threadName;<br />
<br />
this.MyThreadList.Add(t);<br />
}<br />
But Im not sure - it seems to work but is it healthy?
Thanks for the advice on ParameterizedThreadStart - will check it out immediately!
Gerry
|
|
|
|
|
You are welcome .
I believe that you still use a Generic List to add threads? Giving a thread a name in a list is possible but has to disadvantages:
1- You have to iterate through all the list to get a certain thread with a name
2- Unlike a Dictionary , you can add 2 threads with the same name, which could be confusing and very error brone.
That's why I recommended a dictionary<string, Thread> to take care of all these validations for you.
gvanto wrote: it seems to work but is it healthy?
You mean the list? That's what I said above, but if you mean something else, what is it, and what makes you think it's unhealthy?
Regards
|
|
|
|
|
Hi Nader,
ACtually, as it happens I dont really need to reference the threads by name, but rather I do it by their index number:
MyThreadList[i].Start(); etc...
But I'm taking all your ideas on board as I am sure in the very near future I will hit a dead-end and will require more flexibility (as usual!) But so far the use of this threading (instead of ThreadPool) has been great - seems to be faster and I can actually kill threads midway through as required.
Thanks again Nader, I'll be on this thread again soon I am sure!
Until then!
Gerry
|
|
|
|
|
Hi Nader,
ACtually, as it happens I dont really need to reference the threads by name, but rather I do it by their index number:
MyThreadList[i].Start(); etc...
But I'm taking all your ideas on board as I am sure in the very near future I will hit a dead-end and will require more flexibility (as usual!) But so far the use of this threading (instead of ThreadPool) has been great - seems to be faster and I can actually kill threads midway through as required.
Thanks again Nader, I'll be on this thread again soon I am sure!
Until then!
Gerry
CrazyWebmaster
|
|
|
|
|
hi
i am use .Net 2.0 (VS2005)
i want to add Key to my app.cong and give it value but i don't know how to do this . somebody say me
use this code :
using System.Configuration; //add ref to System.Configuration.dll
//-------------------------------------
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add("Color", "Red");
config.Save(ConfigurationSaveMode.Full);
but i doesn't found Configuration,ConfigurationManager in System.Configuration Namespace .. please help me how to solve my problem and save application seeting in app.cong and retrive it later.
thanks
|
|
|
|
|
try to add key and value in following way
ConfigurationSettings.AppSettings.Add(keyname,value);
rahul
|
|
|
|
|
OK .. I was done your suggestion but the Following error shown me :
The configuration is read only.
and my other problem is that : Where does ConfigurationManager and how to use it ? (ConfigurationManager does not exist in my project solution or System.Configuration Namespace)
i am using .net 2.0 .
thanks .
|
|
|
|
|
|
hi, got a question:
i have a windows form app. it has a picturebox of a button that says "Search". however i want to be able to support multiple languages. how do i do this?
putting a label on top of a picturebox and making the background transparent doent work. i just get a grayed out area with the new label on the picturebox.
i have a configuration file that allows you to modify certain stuff. i could add a field in here to use a different picturebox instead of the default one. or is there a completely different way to do it?
will having a button with a picture and changing text work? somehow i doubt it.
thanks.
|
|
|
|
|
You can have a bitmap without any text and render the text directly on the bitmap before setting it on the button.
Be prepared to handle different length in text though, either by having a bitmap you can stretch, or possible by having it available in different sizes.
Obviously the best option is simply avoid the problem by using text only buttons, but I am aware that in reality stupidity and bad GUI design can't be avoided as too many people with too few skills are allowed to make decissions.
|
|
|
|
|
lmoelleb, how would i render the text onto the bitmap?
that's the part i'm having a problem with.
also, if there is a better way to have dynamic text on an image,
i'd love to know how to do it.
thanks for the help!
|
|
|
|
|
Good morning to all Programming Gurus...
I need an Advice for sending Data over an LAN.
I've written an Windows-Service to check several Network-Clients if they are Available (Pinging these Clients).
If any Error occurs the service should notify some distributed Clients on the Network.
Can anyone give me an Hint how to distribute these Error???
I've already tried to use Sockets but i'm not sure how to format the Object to be sent...
Is there an posibility to use Remoting?
* Can i use an Remotingserver to send Messages?
Or do i have to register an Channel for each Client?
NOTE: The Error is an Serializable Object storing the Information.
THX for your Help...
-- modified at 8:01 Friday 22nd September, 2006
|
|
|
|
|
hey, I'm not sure I understood you completly and I'm also not sure its the best solution, but its something. (after all I'm just a student...)
The best idea, is simply sending them e-mail. you can use SMTP client or simply a "mailto:" process. also SMS is possible to notify the problem, if you have a gateway available.
if you want something you build on your own, you can use a service on the distributed list and send them a message from the checking computer in case of failure.
hope it helps.
|
|
|
|
|
Thx for your Suggestion using Mail, but i want to use Mail if there is no Client loged onto the service.
Has anyone out there already tried to convert an Object into an byte[]???
Then i should be able to use Sockets...
|
|
|
|
|
to convert object to byte[] look for a static method in the File class (not sure its name, it converts an object to bytes).
another thing, you can use SMTPclient object to send e-mail.
|
|
|
|
|
Hi
I have to add some functionality to a test harness. I have been given the whole solution which includes a web reference that contains classes ending in Wse. When i regenerate reference.cs (this file is generated from a schema related to the web service) it is correct according to the schema however the classes don't have wse functionality nor the Wse appended on to the end of the function name and so there are build errors functionNameWse does not exist in namepace...... as functionNameWse is autogenerated to functionName.
I am using VS2003 and it appears the WSE capability was generated previously using WSE 1.0 - no idea of the service pack though
Does any one know how i can correct this?
Thanks
Dan
|
|
|
|
|
Its ok i fixed this problem - for any one who may come against the same problem i used this tool: microsoft_wse_1.0_settings_tool - found it on google.
|
|
|
|
|
Hi Dear All Respected Programmers
I am having problem with following mentioned method when I try to write in C#. following mention method is belonged with VB6 kindly convert it into C#.
Thank you
dim strChecker as string
strChecker = "Z"
Text1.text = iif(strChecker="Z","Good","Bad")
|
|
|
|
|
M Riaz Bashir wrote: Text1.text = iif(strChecker="Z","Good","Bad")
Text1.Text = (strChecker == "Z") ? "Good" : "Bad";
Its called a Ternary operator I think. But don;t quote me on that!
|
|
|
|
|
J4amieC wrote:
Its called a Ternary operator I think. But don;t quote me on that!
That is correct. It's called a conditional or a ternary operator.
And you can quote me on that.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks Guffa, had a brain fart moment and couldnt think whether id made the name up or not...
|
|
|
|
|
Hi all,
I have posted a similar question before... I asked how i could trim a way the last character if it is a ",". And i got loads of ways, thanks.
Now i want to know how to trim away more than one character.
would it work, if i use one of the examples someone gave me, to do it like this...
strName[strName.Length-1] = string.Empty;
But if i make the "Length-1" part where the "-1" is the number of character i want to trim, would this be correct?
Thank you in advance
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Simplest solution I can think of is using SubString method:
strName.SubString(0, strName.Length - 4);
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
thank you...
i used that example to get rid of one caracter aswell.
so am i understanding this right if i say that the "-4" or "-1" would be the amount of caracter to be left out from the end?
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|