CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Feb 2003
    Location
    Ft. Worth Texas
    Posts
    31

    [RESOLVED] Using SendOrPostCallback

    Hello,
    I'm hoping someone can help me with this. I'm new to C#, and can't figure out how to correct this.
    I get the error: No overload for 'Lbl39Text' matches delegate 'System.Threading.SendOrPostCallback'

    I'm using VS2010.

    See the attached offending code (in red)!

    Thanks!


    Code:
    private void Lbl39Text(string NewText)
            {
                this.Label39.Text = NewText;
                this.Refresh();
            }

    Code:
    if (this.Label39.InvokeRequired) {
          // It's on a different thread, so use Invoke.
    
          SendOrPostCallback d1 = new SendOrPostCallback(Lbl39Text);      
          this.Invoke(d1, new object[] { NewText });
    } else {
         // It's on the same thread, no need for Invoke.
         this.Label39.Text = NewText;
         Refresh();
    }
    Last edited by KKW; June 13th, 2011 at 09:14 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured