locked
Parms [] object help needed RRS feed

  • Question

  • Hello

                see the code below 

     

    void OnDataReceivedEnd(string message, SomeClass name)

            {

                try

                {

                    //if (this.InvokeRequired)

                    //{

                    //    this.Invoke(new Action<string>(OnDataReceivedEnd), message);  HOW CAN I SEND PARMS OBJECT HERE

                    //    return;

                    //}


    It's Me
    Thursday, June 2, 2011 5:33 AM

All replies

  • Try

    this.Invoke(new Action<string>(OnDataReceivedEnd), new string[] { message });
    

    A brief explanation on params keyword

    http://msdn.microsoft.com/en-us/library/w5zay9db%28v=vs.71%29.aspx


    Thanks,
    A.m.a.L Hashim
    Microsoft Most Valuable Professional
    Dot Net Goodies
    Don't hate the hacker, hate the code
    • Marked as answer by Jackie-Sun Tuesday, June 14, 2011 8:58 AM
    • Unmarked as answer by Jackie-Sun Wednesday, June 15, 2011 2:03 AM
    Thursday, June 2, 2011 5:58 AM
  • this.Invoke(new Action<string>(OnDataReceivedEnd), message)

    That line should work as it is. The compiler will automatically create an array to store the parameters.

    Friday, June 3, 2011 10:11 AM
  • Hi,

    How about your issue? Do you have any update? I am waiting...

     

    Good day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 6, 2011 6:54 AM
  • Wrong answer, the delegate should be used on the same parameters method, so the code should change to:

    this.Invoke(new Action<string, SomeClass>(OnDataReceivedEnd), new string[] { message, name });

    J


    Best day, Best life
    • Proposed as answer by Louis.fr Wednesday, June 15, 2011 3:57 PM
    • Marked as answer by Jackie-Sun Tuesday, June 21, 2011 7:01 AM
    • Unmarked as answer by It_s Meee Wednesday, July 27, 2011 7:19 AM
    Tuesday, June 14, 2011 11:42 AM