Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Retriving data from a irc server

Retriving data from a irc server

Scheduled Pinned Locked Moved C#
questionsysadminhelptutorial
6 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Casper Hansen
    wrote on last edited by
    #1

    Hello. I have been creating a simple irc client that connects to a server and sends some simple commands to it I have also figured out how to retrive data from the server by using streams The problem is I have to run a never-ending while to keep retriving all the data from the server I do it like this:

            while ((inputLine = reader.ReadLine()) == null)
            {
                listBox1.Items.Add(reader.ReadLine());
            }
    

    The problem is that my form doesent respond (I cant use buttons, and such) since the while is never-ending Is there any way of adding a event that triggers when there is new data from the server? Here is my project: dumpen.dk/include/files/IrcBot.rar And a bonus question: When connecting to Quakenet and joining a channel it says: 451 Register first Why is that?

    C C 2 Replies Last reply
    0
    • C Casper Hansen

      Hello. I have been creating a simple irc client that connects to a server and sends some simple commands to it I have also figured out how to retrive data from the server by using streams The problem is I have to run a never-ending while to keep retriving all the data from the server I do it like this:

              while ((inputLine = reader.ReadLine()) == null)
              {
                  listBox1.Items.Add(reader.ReadLine());
              }
      

      The problem is that my form doesent respond (I cant use buttons, and such) since the while is never-ending Is there any way of adding a event that triggers when there is new data from the server? Here is my project: dumpen.dk/include/files/IrcBot.rar And a bonus question: When connecting to Quakenet and joining a channel it says: 451 Register first Why is that?

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Casper Hansen wrote:

      while ((inputLine = reader.ReadLine()) == null) { listBox1.Items.Add(reader.ReadLine()); }

      Are you sure that logic is correct? You have essentially written this: While the reader is exhausted add the next line to the list box. This will go into an infinite loop and effectively block your program for eternity, or until you externally kill the process, or until the memory of all those empty items in the list box is exhausted.

      Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

      C 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Casper Hansen wrote:

        while ((inputLine = reader.ReadLine()) == null) { listBox1.Items.Add(reader.ReadLine()); }

        Are you sure that logic is correct? You have essentially written this: While the reader is exhausted add the next line to the list box. This will go into an infinite loop and effectively block your program for eternity, or until you externally kill the process, or until the memory of all those empty items in the list box is exhausted.

        Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

        C Offline
        C Offline
        Casper Hansen
        wrote on last edited by
        #3

        Well no :P Thats why I ask here since I cant seem to come up with a solution

        C 1 Reply Last reply
        0
        • C Casper Hansen

          Well no :P Thats why I ask here since I cant seem to come up with a solution

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Actually, your question was about whether a specific feature was available in a framework. You did not question the logic.

          Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

          C 1 Reply Last reply
          0
          • C Colin Angus Mackay

            Actually, your question was about whether a specific feature was available in a framework. You did not question the logic.

            Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

            C Offline
            C Offline
            Casper Hansen
            wrote on last edited by
            #5

            I would like help with the logic as well or just some other soloution for my problem

            1 Reply Last reply
            0
            • C Casper Hansen

              Hello. I have been creating a simple irc client that connects to a server and sends some simple commands to it I have also figured out how to retrive data from the server by using streams The problem is I have to run a never-ending while to keep retriving all the data from the server I do it like this:

                      while ((inputLine = reader.ReadLine()) == null)
                      {
                          listBox1.Items.Add(reader.ReadLine());
                      }
              

              The problem is that my form doesent respond (I cant use buttons, and such) since the while is never-ending Is there any way of adding a event that triggers when there is new data from the server? Here is my project: dumpen.dk/include/files/IrcBot.rar And a bonus question: When connecting to Quakenet and joining a channel it says: 451 Register first Why is that?

              C Offline
              C Offline
              Casper Hansen
              wrote on last edited by
              #6

              Is this the correct way of using thread?

              using System;
              using System.Windows.Forms;

              namespace mutlithread
              {
              public partial class Form1 : Form
              {
              public Form1()
              {
              InitializeComponent();
              }

                  // Event handler
                  void FakeUIUpdater(string textboxText)
                  {
                      // Create a new delegate updater
                      UIUpdaterDelegate updateUI = new UIUpdaterDelegate(UpdateUI);
              
                      // Send the delegate to the winform
                      this.Invoke(updateUI, new object\[\] { textboxText });
                  }
              
                  // Create the delegate
                  delegate void UIUpdaterDelegate(string textboxText);
              
                  // Update the user interface with the arguments set earlier in fakeuiupdater
                  protected void UpdateUI(string textboxText)
                  {
                      textBox1.Text = textboxText;
                  }
              
                  private void button1\_Click(object sender, EventArgs e)
                  {
                      FakeUIUpdater("test");
                  }
              }
              

              }

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups