Thread: Multiple Object Declarations

  1. #1
    Super Moderator
    Join Date
    Sep 2001

    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?

    while (Status = true)
    	Thread ClientThread = (new ThreadStart(Client.Http());

    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.

  2. #2
    Banal internet user
    Join Date
    Aug 2002
    The GC will take care of it.

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Nice... I love this language... Does the same apply for Sockets? Each thread has a socket paired with it...

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    The same applies to any object in C#

    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. circular doubly linked list help
    By gunnerz in forum C++ Programming
    Replies: 5
    Last Post: 04-28-2007, 08:38 PM
  2. Animating Multiple Object - [Open Gl]
    By Tonto in forum Game Programming
    Replies: 6
    Last Post: 09-29-2006, 06:31 PM
  3. Linked List Templates and Object Types
    By ventolin in forum C++ Programming
    Replies: 10
    Last Post: 06-16-2004, 12:05 PM
  4. Replies: 1
    Last Post: 05-01-2003, 02:52 PM
  5. multiple object instances at runtime
    By mrukok in forum C++ Programming
    Replies: 1
    Last Post: 03-25-2003, 07:26 AM