Activity Stream
48,167 MEMBERS
62806 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 6 of 6
  1.     
    #1
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com

    Default [C#] Difference with Invoke and Threading

    Im just wondering, is there any benefits when it comes to Invoke or Threading.

    and what's the difference:

    PHP Code: 

    namespace Test
    {
        
    publuc class MyBox Form()
        {
             public 
    delgate SomeDelegate();

             public 
    void MyBox()
             {
                 
    InitializeComponant();
                 
                 
    SomeLibrary.OnFinished += new SomeDelegate(Method);
             }

            public 
    void Method()
           {
               if(
    InvokeRequired)
               {
                   new 
    SomeDelegate(Method);
                   return;
               }
                
    //Access Here :/
           
    }
        }

    So my point is, if i start using the Invoke throughout my applications, will there be some down side ?
    litewarez Reviewed by litewarez on . [C#] Difference with Invoke and Threading Im just wondering, is there any benefits when it comes to Invoke or Threading. and what's the difference: namespace Test { publuc class MyBox : Form() { Rating: 5
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  2.   Sponsored Links

  3.     
    #2
    Respected Developer
    The Control.Invoke() method and Thread object are completely different so they can't have benefits over each other.

    And what's the difference between what?

    Why would there be some downside? Invoking is something that is required for doing cross thread calls.

  4.     
    #3
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    I mean, When you use Control.Invoke, Is that Invoking a method on another Thread, or is that creating a new thread and then invoking the method.

    Also, By doing new Thread(new Action(() => SomeClass,new object[] {this});.. Does that create a new thread and runs the object within that thread, and then to use that class i would have to use a Invoke?

    Sorry ive just learnt that Invoking stops plenty of errors , and wanted to understand it a little more.
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  5.     
    #4
    Respected Developer
    The Action object is just a delegate. See this is why I keep advising people to read a book, because it answers most of these type of questions.

    Read these:
    - delegates http://www.aspfree.com/c/a/C-Sharp/C...tes-Explained/
    - Invoke http://weblogs.asp.net/justin_rogers/pages/126345.aspx

    They should clarify it a bit.

  6.     
    #5
    ლ(ಠ益ಠლ)
    Website's:
    extremecoderz.com
    You need to understand threading. If a thread is trying to access an object that it did not create, you need to invoke that object.

    Example:

    Main Thread: The initial thread used to create the program.
    - Draws a textBox called TextBox1
    - Draws a button called button1

    Thread2 - self-created Thread.
    - Tries to access TextBox1.
    - Is returned an error "cannot access object thread did not create".
    - Solution: Invoke the object.

    This is a common example of useage for invoking objects whilst using threading.

  7.     
    #6
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Yea looks like i was off the mark with separating Threads and Invoking
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Difference between VPS-RDP
    By zoug100 in forum Hosting Discussion
    Replies: 7
    Last Post: 30th Sep 2011, 12:40 PM
  2. difference?
    By raghuram in forum Hosting Discussion
    Replies: 2
    Last Post: 8th Aug 2010, 04:10 PM
  3. [c#] Multi-Threading and keeping the GUI useable.
    By jayfella in forum Web Development Area
    Replies: 0
    Last Post: 18th Jun 2010, 12:07 AM
  4. [PHP] Threading Class
    By SplitIce in forum Tutorials and Guides
    Replies: 8
    Last Post: 1st Oct 2009, 01:24 AM

Tags for this Thread

BE SOCIAL