C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-25-2004, 09:43 PM   #1
Super Moderator
 
Join Date: Sep 2001
Posts: 4,746
Multiple Object Declarations

I'm finishing up that server I was writing in C# and just noticed a problem. A lot of what I've written has been learned from other source code I've seen, as I've had no previous experience in network programming. One problem I just noticed from something I had seen is this:

The server sets up a socket that acts as a listener. Every time that socket recieves a request it starts a new thread to process that request. Basically I have a while loop that will cycle until the user tells the server to stop accepting requests. In that loop, a thread is declared, which means I'm going to have multiple declarations. This was on example source code from a seemingly reliable source, so I ignored it before now. Can anyone think of a way around this if this is indeed a problem?

Code:
while (Status = true)
{
	Thread ClientThread = (new ThreadStart(Client.Http());
	ClientThread.Start();
} 


edit: The above source code has been oversimplified to illustrate only the problem at hand. The threads are only created after a request has been recieved.
sean is offline   Reply With Quote
Old 09-25-2004, 11:15 PM   #2
BMJ
Registered User
 
Join Date: Aug 2002
Posts: 1,330
The GC will take care of it.
BMJ is offline   Reply With Quote
Old 09-26-2004, 06:05 PM   #3
Super Moderator
 
Join Date: Sep 2001
Posts: 4,746
Nice... I love this language... Does the same apply for Sockets? Each thread has a socket paired with it...
sean is offline   Reply With Quote
Old 09-26-2004, 10:42 PM   #4
the hat of redundancy hat
 
nvoigt's Avatar
 
Join Date: Aug 2001
Location: Hannover, Germany
Posts: 2,770
The same applies to any object in C#
__________________
hth
-nv

She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

When in doubt, read the FAQ.
Then ask a smart question.
nvoigt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
circular doubly linked list help gunnerz C++ Programming 5 04-28-2007 08:38 PM
Animating Multiple Object - [Open Gl] Tonto Game Programming 6 09-29-2006 06:31 PM
Linked List Templates and Object Types ventolin C++ Programming 10 06-16-2004 12:05 PM
Using multiple source files: Multiple Declarations & Wrong line numbers Inquirer C++ Programming 1 05-01-2003 02:52 PM
multiple object instances at runtime mrukok C++ Programming 1 03-25-2003 07:26 AM


All times are GMT -6. The time now is 02:55 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22