Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
Esofter #1
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Subject: Trouble with Invoke.
Hi.
I have a problem in this hundler

  1. private void XmppCon_OnLogin(object sender)
  2. {
  3.     if (InvokeRequired)
  4.     {
  5.         // Windows Forms are not Thread Safe, we need to invoke this :(
  6.         // We're not in the UI thread, so we need to call BeginInvoke              
  7.         BeginInvoke(new ObjectHandler(XmppCon_OnLogin), new object[] { sender });
  8.         return;
  9.     }
  10.     lblStatusConn.Text = "Logged";
  11. }

Sometimes I have exception in row   lblStatusConn.Text = "Logged"; that object lblStatusConn does not created in this thread and we can't modify his property.
I noticed that this exception occured when we have weak speed of channel of connection. How I may fix this trouble?
Thank you.
Avatar
Alex #2
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
If you are using SWF for the GUI your code looks correct.
Avatar
Esofter #3
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Quote by Alex:
If you are using SWF for the GUI your code looks correct.

For GUI I use Winforms.
Avatar
ayyrk #4
Member since Jul 2007 · 92 posts
Group memberships: Members
Show profile · Link to this post
Subject: try this
Just and idea try replacing the if with this:      if (lblStatusConn.InvokeRequired)  {
Avatar
Esofter #5
Member since Oct 2009 · 20 posts
Group memberships: Members
Show profile · Link to this post
Quote by ayyrk:
Just and idea try replacing the if with this:      if (lblStatusConn.InvokeRequired)  {

Thank you, I will try.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS