CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2013
    Posts
    2

    Cool Asking for an Advice

    I am totaly a newbie of C# and developing.
    I am trying to build a solution that has to use a socket.
    So far I got quite honest results.

    A part of my code is made in this way:


    Code:
    while (true)
                        {
                          
                            try
                            {
    
                                data1 = mystreamreader.ReadLine();
                                listBox1.Items.Add(data1);
                                i++;
                                //MessageBox.Show(data1);
                            }
                            catch
                            {
                               
                            }
                            
                        }
    As you can see this is a loop that permit me to have a push on a TCP stream (by using Socket).
    The problem is that while the while loop is going my application works but is almost frozen. So is impossible to proceed with others threads.

    I would like to use the multithreading tecnology but I don't know how to implement it. I mean ... how I can call method in a thread class of objects that are defined in other parts of the code?

    Can you help me giving some advices or solution
    Thanks in advance

  2. #2
    Join Date
    Oct 2004
    Location
    Rocket City
    Posts
    220

    Re: Asking for an Advice

    How do you exit from the while (true) block?

  3. #3
    Join Date
    Aug 2013
    Posts
    2

    Re: Asking for an Advice

    Quote Originally Posted by zips View Post
    How do you exit from the while (true) block?
    Actually I don't need to quit. The only thing might be I can changhe the while condition.

    Any advices on threading using?

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Asking for an Advice

    Search bing or google for "Using a thread in Windows Forms example".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured