Storing a Form in a Hashtable
- From: "tcomer" <tcomer@xxxxxxxxx>
- Date: 7 Dec 2006 09:49:48 -0800
I'm working on a chat client and this is what I'm trying to do when a
message is received:
private void ReceivedMessage_Event(object sender,
ClientEventArgs e)
{
// the ChatWindow class is derived from a simple form
ChatWindow pm;
try
{
if (e.CommandType == CommandType.PrivateMessage)
{
// check to see if there is already a chat window
open
if (this.m_ChatTable.ContainsKey(e.SenderName))
{
// add the new message to the chat window
pm =
(ChatWindow)this.m_ChatTable[e.SenderName];
pm.AddMessage(e.MessageText);
}
else
{
// there is no window open so we have to create
one and show the form and the message
pm = new ChatWindow(e.SenderName,
this.m_userName);
pm.PrivateMessageSent += new
ChatWindow.PrivateMessageEventHandler(ChatWindow_PrivateMessageSent);
pm.FormClosing += new
FormClosingEventHandler(ChatWindow_FormClosing);
this.m_ChatTable.Add(e.SenderName, pm);
pm.AddMessage(e.MessageText);
pm.ShowDialog();
}
}
}
catch (InvalidOperationException ioe)
{
MessageBox.Show(ioe.StackTrace);
}
I'm getting a "System.InvalidOperationException occured in
MyProgram.exe" message. But the exception is only thrown when I close
the ChatWindow that is created in the "else" block. I've placed
try/catch blocks around every statement in my application but it still
goes unhandled. I'm willing to provide any code that may help you
understand what I'm trying to do. Right now this is the code that I
beleive is the most relevant. Please let me know if I need to provide
more information.
.
- Follow-Ups:
- Re: Storing a Form in a Hashtable
- From: Bruce Wood
- Re: Storing a Form in a Hashtable
- Prev by Date: Re: Clear Password String in C# Compiled Code
- Next by Date: Re: Storing a Form in a Hashtable
- Previous by thread: Re: StreamReader ReadLine alternate End Of Line
- Next by thread: Re: Storing a Form in a Hashtable
- Index(es):
Relevant Pages
|