+ Reply to Thread
Results 1 to 2 of 2

Thread: Advanced Threading in C#

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    28

    Advanced Threading in C#

    I know how to do threading but i'd like to know how can i do a threading function that takes more than 1 parameter or even 1 parameter?
    Last edited by reachel; 10-31-2012 at 04:07 AM.

  2. #2
    Before starting that tutorial i`d like you to view a threading tutorial posted HERE in CodeExperts.

    So , Sometimes you want to thread a method that takes [0 or 1 or more than 1 parameter]

    To Use threading with 0 parameter ?
    Code:
            // Method is >> MethodName() , but inside ThreadStart it will be without "(" and ")"
            Thread thread = new Thread(new ThreadStart(MethodName));
            thread.Start();
    To Use threading with 1 parameter ?
    Code:
            // My Method name is Print(String)
            Thread protect = new Thread(o => { Print((string)o); });
            protect.Start("STRING TEXT");
    To Use threading with more than 1 parameter ?
    Code:
    		// in case each parameter is a string
            Thread thread = new Thread(() => Method("parameter 1", "parameter 2", "parameter 3"));
            thread.Start();

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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