|
Hum Dum wrote: When we assign a task to thread does it completes it and stops there.
It executes the method and returns. When method execution is done, thread ends.
Hum Dum wrote: then creating same thread again and again (if we are using that work frequently) going to create any overhead?
You are not using the same thread. Each time a new thread will be created. There is an overhead associated with creating threads. It is negligible for small number of threads.
Hum Dum wrote: Do you spot me to any link for threading or refer me a book on networking and threading.
Here is one for threading[^]. Here[^] is one MSDN article on network programming.
|
|
|
|
|
I debugged the application, when i press start button i.e calling Initialize()(after stopping thru stop), it jumps to ListenThread() method,
when server.Start(); //this lines comes, it exit thread by saying code with 0
but if i use server.Stop() in UnInitialize(), then its working fine.
Now, other problem is, what if server is already stopped, how can i check TcpListner state. (for server variable plz see original post, In ListenThread() method)
regards.
|
|
|
|
|
Just disable the start button when clicked and enable it back after pressing stop. This will prevent unnecessary clicks on the start button. I am not sure, but TcpListener.Active[^] should give you the status of listener.
|
|
|
|
|
Hello,
I'm trying to open a datetimepicker control when i'm clicking on different button,
but i can't find the right property/function at the picker.
I tried -
dateTimePickerHourString.Select();
but i got "NULL REFERENCE..."
What i'm doing wrong??
|
|
|
|
|
tamir901 wrote: What i'm doing wrong??
Have you initialized dateTimePickerHourString ?
|
|
|
|
|
Richard MacCutchan wrote: Have you initialized dateTimePickerHourString?
It gets the current time and date
|
|
|
|
|
tamir901 wrote: It gets the current time and date
Have you actually checked through the debugger that it has been initialised, as it is unlikely to complain of a NULL reference otherwise.
|
|
|
|
|
Hello,
I want to set the bounds or width of my custom treenode in a winforms application.
Can anyone help me to achive this task?
Thanks,
|
|
|
|
|
Override the OnDrawNode method of the applicable TreeView
Hope this helps!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have used the following code. when the "Quescnt" and the "max value(Int32.Parse(ds.Tables[1].Rows[cnt-1][0].ToString()))" are equal, its going to infinite loop.
static int TheSeed = (int)DateTime.Now.Ticks;
Random RandomClass = new Random(TheSeed);
string Randomnos = string.Empty;
for (int i = 0; i < Quescnt ; i++)
{
int RandomNumber = RandomClass.Next(Int32.Parse(ds.Tables[1].Rows[0][0].ToString()), Int32.Parse(ds.Tables[1].Rows[cnt-1][0].ToString()));
if (!Randomnos.ToString().Contains(RandomNumber.ToString() + ","))
{
Randomnos = Randomnos + RandomNumber.ToString() + ", ";
}
else
{
Quescnt++;
}
}
|
|
|
|
|
This code is a disaster ? what on earth are you trying to do ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Firstly, use the "code block" button to preserve your formatting when posting code fragments - it makes it easier to read.
I have pared your fragment down to the relevent bits:
string Randomnos = string.Empty;
for (int i = 0; i < Quescnt ; i++)
{
int RandomNumber = RandomClass.Next();
if (!Randomnos.ToString().Contains(RandomNumber.ToString() + ","))
{
Randomnos = "Not an empty string any more.";
}
else
{
Quescnt++;
}
}
So, when you first enter the loop, and Randomnos == "", what is going to happen?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Well spotted. I found the whole thing far too hard to read, and I always like in the first instance to try to get these people to at least try to use the debugger before asking us to do their job for them.
I am losing all faith in development as a respectable profession. I think I should become a plumber.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Whenever I see a loop termination variable that changes in the loop, I just think: "where do they get these people?"
Christian Graus wrote: I think I should become a plumber
Not a bad choice: in the UK at least, you can earn more for less work!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Yes, I agree.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: I think I should become a plumber.
I've been thinking electrician. Plumbing was an idea, but you end up having to deal with septic tanks and pipes clogged with things no one ever wants to know about.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
I wonder if you can help me?
I've been trying to fit a new washer to my kitchen tap for some time. Should I use C# or VB.Net for this?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Neither - it's a hardware problem...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
hi thanks for the reply.
i want to copy all the random's numbers in a string separating by a comma.
i.e Randomnos = "2,5,3,1,4";
This "Quescnt" comes from database.
when this Quescnt and the MaxValue in RandomClass.Next(Min, Max) are equal, its going to infinite loop.
|
|
|
|
|
And why is that ? Have you used the debugger to see what is going on ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
vasavi.p wrote: when this Quescnt and the MaxValue in RandomClass.Next(Min, Max) are equal, its going to infinite loop
No, it's going to infinite loop under all circumstances.
Try running it though the debugger. What is your "code" actually doing?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
There's a debugger ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yeah - you just have to enable it:
Type "Format c: /s" at a command prompt and press ENTER. Just say YES to any of those silly questions, you don't need to read them...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I'll stop pressing ENTER before using this debugger.
|
|
|
|
|
hi
try with the below code
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "";
int Quescnt = 6;
string Randomnos = string.Empty;
for (int i = 0; i < Quescnt; i++)
{
int RandomNumber = RandomClass.Next(28, 37);
if (!Randomnos.ToString().Contains(RandomNumber.ToString() + ","))
{
Randomnos = Randomnos + RandomNumber.ToString() + ", ";
}
else
{
Quescnt++;
}
}
Label1.Text = Randomnos;
}
and try with this too[this will go to infinite loop]
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "";
int Quescnt = 6;
string Randomnos = string.Empty;
for (int i = 0; i < Quescnt; i++)
{
int RandomNumber = RandomClass.Next(28, 33);
if (!Randomnos.ToString().Contains(RandomNumber.ToString() + ","))
{
Randomnos = Randomnos + RandomNumber.ToString() + ", ";
}
else
{
Quescnt++;
}
}
Label1.Text = Randomnos;
}
|
|
|
|