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

  • SEARCH
  • Home
  • 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

I'm binding a domain objects property to the Text property of a System.Windows.Forms.Label using
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GenericCount { class Program {
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; namespace ConsoleApplication1 { public
I am using System.Windows.Forms.RichTextBox and doing something like RichTextBox1.Text = Hello World; But after
I have a little demonstration below of a peculiar problem. using System; using System.Windows.Forms;
I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display
I'm writing a custom control derived from System.Windows.Forms.Control . The control is using the
I'm trying to build a Windows installer using Nullsoft Install System that requires installation
I try to add an addons system to my Windows.Net application using Reflection; but
Currently using System.Web.UI.WebControls.FileUpload wrapped in our own control. We have licenses for Telerik. I

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.