Re: Problem with multithread
Can you please wrap your code in [CODE] tags so we can read it?
Re: Problem with multithread
the code id:
the main class:
Code:
public partial class mainForm : Form
{
public BindingList<EndPoint> endPoints =
new BindingList<EndPoint>();
Listener m_listener = null;
Dictionary<string, string> dicConnection =
new Dictionary<string,string>();
public mainForm()
{
InitializeComponent();
bindingSource1.DataSource = endPoints;
m_listener = new Listener();
m_listener.NewConnectionEvent +=
new Listener.NewConnectionDelegate
(OnNewConnection);
endPoints.ListChanged += new
ListChangedEventHandler
(endPoints_ListChanged);
}
void endPoints_ListChanged(object sender,
ListChangedEventArgs e)
{
EndPoint ep1 = null;
EndPoint ep2 = null;
string value = string.Empty;
if (e.ListChangedType == ListChangedType.ItemAdded)
{
try
{
ep1 = endPoints[endPoints.Count - 1];
if (dicConnection != null &&
dicConnection.Count > 0)
{
if (dicConnection.ContainsKey(ep1.Name))
{
//do some code
//when i reach this section the
// dicConnection is null and does not have
// any element and that is the problem
}
}
catch()
{}
}
void OnNewConnection(Socket soc)
{
endPoints.Add("fff"); // that calls
// endPoints_ListChanged
}
}
the Listener class:
class Listener
{
public delegate void NewConnectionDelegate();
public event NewConnectionDelegate NewConnectionEvent;
public Listener(int port)
{
thread = new Thread(threadProc);
thread.Start();
}
void threadProc()
{
if (NewConnectionEvent != null)
{
NewConnectionEvent();
}
}
}
Re: Problem with multithread
As I already asked, please wrap your code in code tags because it is too hard to read otherwise. Use the button on the advanced editor or else type them manually.
1 Attachment(s)
Re: Problem with multithread
sorry....
i uploaded a txt file. I hope now it will be easy to read it.
Re: Problem with multithread
I don't want to download a text file. I want to be able to read your code in your post. I was more than willing to help but if wrapping the code in tags is too hard then I guess you don't need my help all that much after all.
Re: Problem with multithread
shoham78:
read this page: http://www.codeguru.com/forum/misc.php?do=bbcode
Use code tags in future, please -- and for heaven's sake, format your code nicely when you write it in the first place. If you want help from others you have to make them interested in reading what you wrote. If it's a dogs dinner, they wont bother.
Re: Problem with multithread
Quote:
Originally Posted by jmcilhinney
I don't want to download a text file. I want to be able to read your code in your post. I was more than willing to help but if wrapping the code in tags is too hard then I guess you don't need my help all that much after all.
sadly, it's just as much of a gash mess with them on as off..