I have two threads in c#.. Now i need to wait for a particular statement to be executed before I can continue execution in the other thread which obviously is a case of synchronisation. Is there any code that can carry this out as in using an in-built method?
OK guys.. This is the code example:
    public void StartAccept()
    {
            try
            {
                newSock.BeginAccept(new AsyncCallback(Accepted), newSock);
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Error in arguments while using begin-accept", "Error", MessageBoxButtons.OK);
            }
            catch (ObjectDisposedException)
            {
                MessageBox.Show("socket closed while using begin-accept", "Error", MessageBoxButtons.OK);
            }
            catch (SocketException)
            {
                MessageBox.Show("Error accessing socket while using begin-accept", "Error", MessageBoxButtons.OK);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Invalid operation while using begin-accept", "Error", MessageBoxButtons.OK);
            }
            catch (Exception)
            {
                MessageBox.Show("Exception occurred while using begin-accept", "Error", MessageBoxButtons.OK);
            }
    }
This receives data from the desired host which is selected by the code:
    private void listBox1_Click(object sender, EventArgs e)
    {
        String data = (String)this.listBox1.SelectedItem;
        ip = Dns.GetHostAddresses(data);
        clientIP = new IPEndPoint(ip[0], 5555);
        newSock.Bind(clientIP);
        newSock.Listen(100);
    }
So in order to start receiving data I need to initialise the socket to the particular remote host which is done when i click on one of the hosts shown in the listbox. For this I need the synchronization.
Hope this helps.