Need help for my IRC Client
-
Konnichiwa! ;) I need help from talented C# developpers for my IRC Client for .NET called Aeru IRC. You can found it at: http://www.sourceforge.net/projects/aeruirc/. The newest source is available in CVS(but I can publish nightly CVS tarball on main project page). Summaray how the client works: -The client create a IRCConnection -IRCConnection create a new thread for Connection. -In Connection, ConnectionThread create the ReceiveThread and an instance of the IRCParser class -On each message that Receive the client, the ReceiveThread parse it with IRCParser. -And the IRCParser do the commands for specifics commands, errors and replies. Currently, I have problem implanting the main GUI (using Magic Library). When the client receive a message for create a channel. The VS.NET Debugger raise an exception saying that I can't modify an control(Crownwood.Magic.Controls.TabControl) created in another thread. Contact me to shock@romhack.net(email) and/or shock@shockdev.ca.tc(MSN) if you want to join the project or if you have solutions for my problem. :) Thanks CodeProject folks :-D -Shock The Dark Mage _Trully, if there evil in this world,
It lies within the heart of mankind-Edward D. Morison
_
Shock The Dark Mage shock@romhack.net Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
-
Konnichiwa! ;) I need help from talented C# developpers for my IRC Client for .NET called Aeru IRC. You can found it at: http://www.sourceforge.net/projects/aeruirc/. The newest source is available in CVS(but I can publish nightly CVS tarball on main project page). Summaray how the client works: -The client create a IRCConnection -IRCConnection create a new thread for Connection. -In Connection, ConnectionThread create the ReceiveThread and an instance of the IRCParser class -On each message that Receive the client, the ReceiveThread parse it with IRCParser. -And the IRCParser do the commands for specifics commands, errors and replies. Currently, I have problem implanting the main GUI (using Magic Library). When the client receive a message for create a channel. The VS.NET Debugger raise an exception saying that I can't modify an control(Crownwood.Magic.Controls.TabControl) created in another thread. Contact me to shock@romhack.net(email) and/or shock@shockdev.ca.tc(MSN) if you want to join the project or if you have solutions for my problem. :) Thanks CodeProject folks :-D -Shock The Dark Mage _Trully, if there evil in this world,
It lies within the heart of mankind-Edward D. Morison
_
Shock The Dark Mage shock@romhack.net Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
I have one too! MYrc on SF :) I suggest you use the excellenct Thresher lib for the protocol implementation! Hope this helps :) PS: This have been done too many times. Shock The Dark Mage wrote: The VS.NET Debugger raise an exception saying that I can't modify an control(Crownwood.Magic.Controls.TabControl) created in another thread. Had similar problem. You need to invoke the method that creates new tabs instead of calling it directly! :) DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET low popularity, please visit :)
-
Konnichiwa! ;) I need help from talented C# developpers for my IRC Client for .NET called Aeru IRC. You can found it at: http://www.sourceforge.net/projects/aeruirc/. The newest source is available in CVS(but I can publish nightly CVS tarball on main project page). Summaray how the client works: -The client create a IRCConnection -IRCConnection create a new thread for Connection. -In Connection, ConnectionThread create the ReceiveThread and an instance of the IRCParser class -On each message that Receive the client, the ReceiveThread parse it with IRCParser. -And the IRCParser do the commands for specifics commands, errors and replies. Currently, I have problem implanting the main GUI (using Magic Library). When the client receive a message for create a channel. The VS.NET Debugger raise an exception saying that I can't modify an control(Crownwood.Magic.Controls.TabControl) created in another thread. Contact me to shock@romhack.net(email) and/or shock@shockdev.ca.tc(MSN) if you want to join the project or if you have solutions for my problem. :) Thanks CodeProject folks :-D -Shock The Dark Mage _Trully, if there evil in this world,
It lies within the heart of mankind-Edward D. Morison
_
Shock The Dark Mage shock@romhack.net Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
Can't help you directly - but since you are using the dotnet magic library you could always ask the author - He is a nice man :) I've worked with him and in the end if he says no then you will be no worse off :)
Stupidity dies. The end of future offspring. Evolution wins. - A Darwin Awards Haiku
-
Konnichiwa! ;) I need help from talented C# developpers for my IRC Client for .NET called Aeru IRC. You can found it at: http://www.sourceforge.net/projects/aeruirc/. The newest source is available in CVS(but I can publish nightly CVS tarball on main project page). Summaray how the client works: -The client create a IRCConnection -IRCConnection create a new thread for Connection. -In Connection, ConnectionThread create the ReceiveThread and an instance of the IRCParser class -On each message that Receive the client, the ReceiveThread parse it with IRCParser. -And the IRCParser do the commands for specifics commands, errors and replies. Currently, I have problem implanting the main GUI (using Magic Library). When the client receive a message for create a channel. The VS.NET Debugger raise an exception saying that I can't modify an control(Crownwood.Magic.Controls.TabControl) created in another thread. Contact me to shock@romhack.net(email) and/or shock@shockdev.ca.tc(MSN) if you want to join the project or if you have solutions for my problem. :) Thanks CodeProject folks :-D -Shock The Dark Mage _Trully, if there evil in this world,
It lies within the heart of mankind-Edward D. Morison
_
Shock The Dark Mage shock@romhack.net Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
Shock The Dark Mage wrote: The VS.NET Debugger raise an exception saying that I can't modify an control(Crownwood.Magic.Controls.TabControl) created in another thread. I had this problem in my app but I figured out how to fix it. If you want to modify a control or add a control to a form in other thread the exception will be thrown. My solution is to use the SendMessage function to move the execution process from one thread to the other. Use DllImport to be able to call it in your code.
SendMessage( hHandle, WM_USER + 1, 0, 0 );
hHandle is the window's handle you want to send a message to WM_USER + 1 is the message that the main form will receive. In the main thread you must have a form ( whose handle you passed to SendMessage ). Override the WndProc method
public virtual void WndProc( Message* m )
{
if ( m->Msg == WM_USER + 1 )
{
// Here you can modify ar add control without any problems.
}
}
43 68 65 65 72 73 2c 4d 69 63 68 61 65 6c
-
Shock The Dark Mage wrote: The VS.NET Debugger raise an exception saying that I can't modify an control(Crownwood.Magic.Controls.TabControl) created in another thread. I had this problem in my app but I figured out how to fix it. If you want to modify a control or add a control to a form in other thread the exception will be thrown. My solution is to use the SendMessage function to move the execution process from one thread to the other. Use DllImport to be able to call it in your code.
SendMessage( hHandle, WM_USER + 1, 0, 0 );
hHandle is the window's handle you want to send a message to WM_USER + 1 is the message that the main form will receive. In the main thread you must have a form ( whose handle you passed to SendMessage ). Override the WndProc method
public virtual void WndProc( Message* m )
{
if ( m->Msg == WM_USER + 1 )
{
// Here you can modify ar add control without any problems.
}
}
43 68 65 65 72 73 2c 4d 69 63 68 61 65 6c
WHy WHy Why? Why are you doing it this way when all you need to do is invoke it! [edit] bad example :eek: now fixed[/edit] eg
public void AddControl(Control control)
{
Control.Add(control);
}...
myform.Invoke(((MyForm)myform).AddControl, new TextBox());
.... ;P DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET popularity better now, thank you :)
-
WHy WHy Why? Why are you doing it this way when all you need to do is invoke it! [edit] bad example :eek: now fixed[/edit] eg
public void AddControl(Control control)
{
Control.Add(control);
}...
myform.Invoke(((MyForm)myform).AddControl, new TextBox());
.... ;P DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET popularity better now, thank you :)
Thanks for yours solutions but none worked. Here the function(in MainForm) that add a new tabpage in TabControl
public void AddTabPage(string name, TabType type) { Crownwood.Magic.Controls.TabPage addedtab = new Crownwood.Magic.Controls.TabPage(name); switch(type) { case TabType.Status: TemplateStatusWindow status = new TemplateStatusWindow(this.m_connection); addedtab.Control = status; break; case TabType.Channel: TemplateChannelForm channel = new TemplateChannelForm(name, this.m_connection); addedtab.Control = channel; break; } addedtab.Tag = type; addedtab.Name = "tab"+name; int index = 0; if(this.TabChannels.TabPages.Count == 0) { this.TabChannels.TabPages.Add(addedtab); } else { System.Windows.Forms.MessageBox.Show(System.Threading.Thread.CurrentThread.Name.ToString()); index = this.TabChannels.TabPages.Count; this.TabChannels.TabPages.Insert(index, addedtab); } }
Here is the function called from IRCParser in IRCConnectionpublic void CreateChannelTabPage(string name) { m_parent.AddTabPage(name, TabType.Channel); }
And finnaly, the function that invoke all the chain in the Thread ReceiveThreadprivate void cmd331(string[] args) { if(args[2].IndexOf("#")>-1 || args[2].IndexOf("&")>-1) { string msg = JoinString(args, 3, args.Length); msg = msg.Replace(":", ""); #if Terminal connection.Received("*** No topic set in "+args[2]+crlf); #elif MainForm connection.ReceiveTo("Status", "*** No topic set in "+args[2]+crlf, Color.Red); #endif } else { #if Terminal connection.Received("*** You have joined "+args[3]+crlf); #elif MainForm connection.CreateChannelTabPage(args[3]); #endif } }
Hope this will you help you to help me ;) ^_^ Trully, if there evil in this world,
It lies within the heard of mankind
Shock The Dark Mage shock@romhack.net Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
-
Thanks for yours solutions but none worked. Here the function(in MainForm) that add a new tabpage in TabControl
public void AddTabPage(string name, TabType type) { Crownwood.Magic.Controls.TabPage addedtab = new Crownwood.Magic.Controls.TabPage(name); switch(type) { case TabType.Status: TemplateStatusWindow status = new TemplateStatusWindow(this.m_connection); addedtab.Control = status; break; case TabType.Channel: TemplateChannelForm channel = new TemplateChannelForm(name, this.m_connection); addedtab.Control = channel; break; } addedtab.Tag = type; addedtab.Name = "tab"+name; int index = 0; if(this.TabChannels.TabPages.Count == 0) { this.TabChannels.TabPages.Add(addedtab); } else { System.Windows.Forms.MessageBox.Show(System.Threading.Thread.CurrentThread.Name.ToString()); index = this.TabChannels.TabPages.Count; this.TabChannels.TabPages.Insert(index, addedtab); } }
Here is the function called from IRCParser in IRCConnectionpublic void CreateChannelTabPage(string name) { m_parent.AddTabPage(name, TabType.Channel); }
And finnaly, the function that invoke all the chain in the Thread ReceiveThreadprivate void cmd331(string[] args) { if(args[2].IndexOf("#")>-1 || args[2].IndexOf("&")>-1) { string msg = JoinString(args, 3, args.Length); msg = msg.Replace(":", ""); #if Terminal connection.Received("*** No topic set in "+args[2]+crlf); #elif MainForm connection.ReceiveTo("Status", "*** No topic set in "+args[2]+crlf, Color.Red); #endif } else { #if Terminal connection.Received("*** You have joined "+args[3]+crlf); #elif MainForm connection.CreateChannelTabPage(args[3]); #endif } }
Hope this will you help you to help me ;) ^_^ Trully, if there evil in this world,
It lies within the heard of mankind
Shock The Dark Mage shock@romhack.net Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
Shock The Dark Mage wrote: public void CreateChannelTabPage(string name) { m_parent.AddTabPage(name, TabType.Channel); } change this to:
public void CreateChannelTabPage(string name)
{
if (m_parent.InvokeRequired)
{
m_parent.Invoke(m_parent.AddTabPage, name, TabType.Channel);
}
else m_parent.AddTabPage(name, TabType.Channel);
}Now as you can see, you will invoke the method if needed else it will be called directly. Cheers :) DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET popularity better now, thank you :)
-
WHy WHy Why? Why are you doing it this way when all you need to do is invoke it! [edit] bad example :eek: now fixed[/edit] eg
public void AddControl(Control control)
{
Control.Add(control);
}...
myform.Invoke(((MyForm)myform).AddControl, new TextBox());
.... ;P DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET popularity better now, thank you :)
leppie wrote: WHy WHy Why? Why are you doing it this way when all you need to do is invoke it! Because I haven't known this method. It requires less coding and it's more legible. :) Note that if you check the call stack you'll see that the Framework does the same work I described. So my method is not suitable here but it explains how the Invoke function works. :D
43 68 65 65 72 73 2c 4d 69 63 68 61 65 6c
-
leppie wrote: WHy WHy Why? Why are you doing it this way when all you need to do is invoke it! Because I haven't known this method. It requires less coding and it's more legible. :) Note that if you check the call stack you'll see that the Framework does the same work I described. So my method is not suitable here but it explains how the Invoke function works. :D
43 68 65 65 72 73 2c 4d 69 63 68 61 65 6c
OK, if you so say ;P I doubt i'll ever touch that, but i'll keep it in the back of head :) DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET popularity better now, thank you :)
-
Shock The Dark Mage wrote: public void CreateChannelTabPage(string name) { m_parent.AddTabPage(name, TabType.Channel); } change this to:
public void CreateChannelTabPage(string name)
{
if (m_parent.InvokeRequired)
{
m_parent.Invoke(m_parent.AddTabPage, name, TabType.Channel);
}
else m_parent.AddTabPage(name, TabType.Channel);
}Now as you can see, you will invoke the method if needed else it will be called directly. Cheers :) DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET popularity better now, thank you :)
Thanks leppie. Now it's work. Your code need another thing. You need to declare a delegate because Invoke method require a delegate. In MainForm:
public delegate void AddingChannelTab();
New create CreateChannelTabPage function.public void CreateChannelTabPage(string name) { if (m_parent.InvokeRequired) { try { m_parent.ChannelToAdd = name; AeruIRC.MainForm.AddingChannelTab addingchannel = new AeruIRC.MainForm.AddingChannelTab(m_parent.AddTabPage2); m_parent.Invoke(addingchannel); } catch(Exception ex) { MessageBox.Show(ex.Message); } } else m_parent.AddTabPage(name, TabType.Channel); }
The only problem is invoking the delegate with parameters. But now, I call a function without parameters. But it's work :) :) Trully, if there evil in this world,
It lies within the heard of mankind
Shock The Dark Mage shock@romhack.net Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
-
Thanks leppie. Now it's work. Your code need another thing. You need to declare a delegate because Invoke method require a delegate. In MainForm:
public delegate void AddingChannelTab();
New create CreateChannelTabPage function.public void CreateChannelTabPage(string name) { if (m_parent.InvokeRequired) { try { m_parent.ChannelToAdd = name; AeruIRC.MainForm.AddingChannelTab addingchannel = new AeruIRC.MainForm.AddingChannelTab(m_parent.AddTabPage2); m_parent.Invoke(addingchannel); } catch(Exception ex) { MessageBox.Show(ex.Message); } } else m_parent.AddTabPage(name, TabType.Channel); }
The only problem is invoking the delegate with parameters. But now, I call a function without parameters. But it's work :) :) Trully, if there evil in this world,
It lies within the heard of mankind
Shock The Dark Mage shock@romhack.net Main Project: Aeru IRC - http://www.sf.net/projects/aeruirc
Shock The Dark Mage wrote: Thanks leppie. Now it's work. Your code need another thing. You need to declare a delegate because Invoke method require a delegate. A delegate purely a pointer to a method. Shock The Dark Mage wrote: AeruIRC.MainForm.AddingChannelTab addingchannel = new AeruIRC.MainForm.AddingChannelTab(m_parent.AddTabPage2); That is not correct! You will be creatign a new form every time! You should be doing a cast instead. Cheers :) DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET