Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3284460
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:09:25+00:00 2026-05-17T20:09:25+00:00

using System; using System.Windows.Forms; using agsXMPP; using System.Text; namespace iTalk2 { public partial class

  • 0
using System;
using System.Windows.Forms;
using agsXMPP;
using System.Text;
namespace iTalk2
{
    public partial class Main : Form
    {
        agsXMPP.XmppClientConnection objXmpp;

        public Main()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {

            Console.WriteLine("Logging in. Please wait...");
            Console.ReadLine();
            objXmpp = new agsXMPP.XmppClientConnection();
            agsXMPP.Jid jid = null;
            jid = new agsXMPP.Jid("username" + "@gmail.com");
            objXmpp.Password = "password";
            objXmpp.Username = jid.User;
            objXmpp.Server = jid.Server;
            objXmpp.AutoResolveConnectServer = true;

            try
            {
                objXmpp.OnMessage += messageReceived;
                objXmpp.OnAuthError += loginFailed;
                objXmpp.OnLogin += loggedIn;
                objXmpp.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }

        private void messageReceived(object sender, agsXMPP.protocol.client.Message msg)
        {
            string[] chatMessage = null;
            chatMessage = msg.From.ToString().Split('/');
            agsXMPP.Jid jid = null;
            jid = new agsXMPP.Jid(chatMessage[0]);
            agsXMPP.protocol.client.Message autoReply = null;
            autoReply = new agsXMPP.protocol.client.Message(jid, agsXMPP.protocol.client.MessageType.chat, "This is a test");
            objXmpp.Send(autoReply);
        }

        private void loginFailed(object o, agsXMPP.Xml.Dom.Element el)
        {
            Console.WriteLine("Login failed. Please check your details.");
        }

        private void loggedIn(object o)
        {
            Console.WriteLine("Logged in and Active.");
            lblStatus.Text = "Online";
        }

        private void txtUsername_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void txtPassword_TextChanged(object sender, EventArgs e)
        {

        }

        private void btnlogin_Click(object sender, EventArgs e)
        {

        }

    }

}

This code is not working. the function ‘loggedIn(object o)’ is not working. it says the lblStatus (which is a label) is on another thread. the error window says “Cross-thread operation not valid: Control ‘lblStatus’ accessed from a thread other than the thread it was created on.” thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:09:26+00:00Added an answer on May 17, 2026 at 8:09 pm

    You need to invoke a call on the UI thread. If you add code as follows at the top of the loggedIn method it should work:-

    if(InvokeRequired)
    {
        Invoke(new Action<object>(loggedIn), o);
        return;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The winform: The code: using System; using System.Windows.Forms; namespace DemoApp { public partial class
I have: using System.IO; using System.Windows.Forms; namespace myNamespace1 { public partial class Form1 :
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Threading; namespace ClassLibrary { public
I have the following classes: using System; using System.Windows.Forms; namespace FastEyeControl { public partial
using System; using System.Runtime.InteropServices; using System.Windows.Forms; public static class Program { [STAThread] public static
using System; using System.ComponentModel; using System.Net; using System.Windows.Forms; using Ionic.Zip; namespace downloader { public
Is there anything wrong in my code? using System; using System.Windows.Forms; public class MyProgram
I have the code below: namespace WindowMover { using System.Windows.Forms; static class Logic {
using System; using System.Drawing; using System.IO; using System.Security.Cryptography; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Threading;
So I have the declaration at the beginning of my class file using System.Windows.Forms;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.