coding ASCII = System.Text.Encoding.ASCII;
while(!m_Done)
{
IPEndPoint endpoint = null;
Byte[] data = m_Client.Receive(ref endpoint);
String strData = ASCII.GetString(data);
if( strData.IndexOf(":@") > 0 )
{
Char [] separators = {':'};
String [] vars = strData.Split(separators);
if( vars[0] == m_szHostName ) //主系统已关闭
{
AddToMain("shutting down Listener thread...");
m_Done = true;
}
else
{
AddToMain( vars[0] + " has left the conversation");
}
}
else
{
if(strData.IndexOf(":") > 0)
{
Char [] separators = {':'};
String [] vars = strData.Split(separators);
if( vars[0] != m_szHostName )
{
AddToMain(strData);
}
else
{
AddToMain(strData);
}
}
}
}
t.Abort();
AddToMain("Listener thread finished...");
return;
}
private void AddToMain(string _Message)
{
this.txtMessageMain.Text = this.txtMessageMain.Text + _Message + "\r\n";
}
private void btnEnd_Click(object sender, System.EventArgs e)
{
this.btnStart.Enabled = true;
this.btnJoin.Enabled = true;
try
{
t.Abort();
t.Interrupt();
t2.Abort();
t2.Interrupt();
AddToMain("Closing connection...");
m_Client.DropMulticastGroup(m_GroupAddress);
}
catch
{}
//Terminate();
}
private void btnClose_Click(object sender, System.EventArgs e)
{
try
{
t.Abort();
t.Interrupt();
t2.Abort();
t2.Interrupt();
Terminate() ;
}
catch
{}
while(!m_Done)
{
IPEndPoint endpoint = null;
Byte[] data = m_Client.Receive(ref endpoint);
String strData = ASCII.GetString(data);
if( strData.IndexOf(":@") > 0 )
{
Char [] separators = {':'};
String [] vars = strData.Split(separators);
if( vars[0] == m_szHostName ) //主系统已关闭
{
AddToMain("shutting down Listener thread...");
m_Done = true;
}
else
{
AddToMain( vars[0] + " has left the conversation");
}
}
else
{
if(strData.IndexOf(":") > 0)
{
Char [] separators = {':'};
String [] vars = strData.Split(separators);
if( vars[0] != m_szHostName )
{
AddToMain(strData);
}
else
{
AddToMain(strData);
}
}
}
}
t.Abort();
AddToMain("Listener thread finished...");
return;
}
private void AddToMain(string _Message)
{
this.txtMessageMain.Text = this.txtMessageMain.Text + _Message + "\r\n";
}
private void btnEnd_Click(object sender, System.EventArgs e)
{
this.btnStart.Enabled = true;
this.btnJoin.Enabled = true;
try
{
t.Abort();
t.Interrupt();
t2.Abort();
t2.Interrupt();
AddToMain("Closing connection...");
m_Client.DropMulticastGroup(m_GroupAddress);
}
catch
{}
//Terminate();
}
private void btnClose_Click(object sender, System.EventArgs e)
{
try
{
t.Abort();
t.Interrupt();
t2.Abort();
t2.Interrupt();
Terminate() ;
}
catch
{}
| 对此文章发表了评论 |

