TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
akshay rasalakar
NA
128
9.3k
C# windows chat application
Jun 13 2015 11:00 PM
private void MessageCallBack(IAsyncResult aResult)
{
int size = sck.EndReceiveFrom(aResult, ref epRemote);
if (size > 0)
{
byte[] recevivedData = new byte[1464];
recevivedData = (byte[])aResult.AsyncState;
ASCIIEncoding eEncoding = new ASCIIEncoding();
string recevieMessage = eEncoding.GetString(recevivedData);
listBox1.Items.Add("Friend:" + recevieMessage); //In this Line Im getting error Cross-thread operaation not valid: Control 'listBox1' accessed from a thread other than the thread it was created on
i can send msg to my friend but while receiving the message im getting the error as i mentioned above so pls help me..
}
byte[] buffer = new byte[1500];
sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer);
}
Reply
Answers (
2
)
C# Console Appication
Class Inheritance