Click here to Skip to main content
15,883,817 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem to implement designer at runTime. Pin
Richard MacCutchan22-Jan-11 6:37
mveRichard MacCutchan22-Jan-11 6:37 
AnswerRe: Problem to implement designer at runTime. Pin
Henry Minute21-Jan-11 4:17
Henry Minute21-Jan-11 4:17 
GeneralRe: Problem to implement designer at runTime. Pin
hdv21221-Jan-11 5:45
hdv21221-Jan-11 5:45 
GeneralRe: Problem to implement designer at runTime. Pin
Henry Minute21-Jan-11 5:56
Henry Minute21-Jan-11 5:56 
QuestionC# program to share screen using RDPCOMAPILIB.dll Pin
ayandelhi21-Jan-11 1:54
ayandelhi21-Jan-11 1:54 
AnswerRe: C# program to share screen using RDPCOMAPILIB.dll Pin
Bernhard Hiller21-Jan-11 3:43
Bernhard Hiller21-Jan-11 3:43 
AnswerRe: C# program to share screen using RDPCOMAPILIB.dll Pin
Nexuscan19-Jul-11 16:39
Nexuscan19-Jul-11 16:39 
Questionneed help in Basic Network programming in c# Pin
akosidandan20-Jan-11 17:16
akosidandan20-Jan-11 17:16 
Hello Experts,

I would like to ask if what's wrong with my program. I have created 1 client and 1 server that will accept the message
of the client but I got this error.
Cross-thread operation not valid: Control 'lbConnections' accessed from a thread other than the thread it was created on.


For more details here is my code for the Client that send message to server.
using System;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;

namespace UDP_Client
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            UdpClient udpClient = new UdpClient();
            udpClient.Connect(tbHost.Text, 8080);
            Byte[] sendBytes = Encoding.ASCII.GetBytes("Hello World?");
            udpClient.Send(sendBytes, sendBytes.Length);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}



Here also is the code to my server which were I got the error thats is mention above.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Net;
using System.Net.Sockets;


namespace UDP_Server
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        public void serverThread()
        {
            UdpClient udpClient = new UdpClient(8080);
            while (true)
            {
                IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
                Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
                string returnData = Encoding.ASCII.GetString(receiveBytes);
                lbConnections.Items.Add(RemoteIpEndPoint.Address.ToString() + ":" +
                returnData.ToString()
                );
            }
        }
        

        private void Form1_Load(object sender, EventArgs e)
        {

            Thread thdUDPServer = new Thread(new
                                    ThreadStart(serverThread));
            thdUDPServer.Start();
        }
    }
}


Any comments or suggestion to help is kindly appreciated.

Thanks,
DAN
AnswerRe: need help in Basic Network programming in c# Pin
Praveen Raghuvanshi20-Jan-11 18:36
professionalPraveen Raghuvanshi20-Jan-11 18:36 
QuestionHelp with file search Pin
turbosupramk320-Jan-11 11:56
turbosupramk320-Jan-11 11:56 
AnswerRe: Help with file search PinPopular
Luc Pattyn20-Jan-11 12:38
sitebuilderLuc Pattyn20-Jan-11 12:38 
GeneralRe: Help with file search Pin
turbosupramk320-Jan-11 13:12
turbosupramk320-Jan-11 13:12 
AnswerRe: Help with file search Pin
Luc Pattyn20-Jan-11 13:36
sitebuilderLuc Pattyn20-Jan-11 13:36 
GeneralRe: Help with file search Pin
musefan21-Jan-11 0:55
musefan21-Jan-11 0:55 
AnswerRe: Help with file search Pin
Not Active20-Jan-11 12:54
mentorNot Active20-Jan-11 12:54 
GeneralRe: Help with file search Pin
turbosupramk320-Jan-11 13:12
turbosupramk320-Jan-11 13:12 
GeneralRe: Help with file search Pin
Not Active20-Jan-11 13:23
mentorNot Active20-Jan-11 13:23 
GeneralRe: Help with file search Pin
turbosupramk320-Jan-11 13:49
turbosupramk320-Jan-11 13:49 
AnswerRe: Help with file search Pin
Yusuf20-Jan-11 16:09
Yusuf20-Jan-11 16:09 
QuestionNodes, Script interface/ API and Undo Pin
adamvanner20-Jan-11 8:47
adamvanner20-Jan-11 8:47 
AnswerRe: Nodes, Script interface/ API and Undo Pin
SledgeHammer0120-Jan-11 9:51
SledgeHammer0120-Jan-11 9:51 
GeneralRe: Nodes, Script interface/ API and Undo Pin
adamvanner20-Jan-11 22:43
adamvanner20-Jan-11 22:43 
QuestionAccessing variables during AppDomain.ProcessExit Pin
thatdiceygirl20-Jan-11 5:16
thatdiceygirl20-Jan-11 5:16 
AnswerRe: Accessing variables during AppDomain.ProcessExit Pin
Luc Pattyn20-Jan-11 5:46
sitebuilderLuc Pattyn20-Jan-11 5:46 
GeneralRe: Accessing variables during AppDomain.ProcessExit Pin
thatdiceygirl20-Jan-11 5:56
thatdiceygirl20-Jan-11 5:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.