Multiple Object Declarations

This is a discussion on Multiple Object Declarations within the C# Programming forums, part of the General Programming Boards category; I'm finishing up that server I was writing in C# and just noticed a problem. A lot of what I've ...

  1. #1
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913

    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.

  2. #2
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    The GC will take care of it.

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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
    Location
    Hannover, Germany
    Posts
    3,139
    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.

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, 09:38 PM
  2. Animating Multiple Object - [Open Gl]
    By Tonto in forum Game Programming
    Replies: 6
    Last Post: 09-29-2006, 07:31 PM
  3. Linked List Templates and Object Types
    By ventolin in forum C++ Programming
    Replies: 10
    Last Post: 06-16-2004, 01:05 PM
  4. Replies: 1
    Last Post: 05-01-2003, 03:52 PM
  5. multiple object instances at runtime
    By mrukok in forum C++ Programming
    Replies: 1
    Last Post: 03-25-2003, 07:26 AM

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