Results 1 to 8 of 8

Thread: MultiThread arguments...

  1. #1

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Resolved MultiThread arguments...

    VB Code:
    1. ThreadStart job = new ThreadStart(CatalogRoutine(cmbServer.Text));
    2.             Thread thread = new Thread(job);
    3.             thread.Start();
    4.  
    5.             private void CatalogRoutine(String servername)

    how can I pass an argument???

    it gives me an error on "ThreadStart(CatalogRoutine(cmbServer.Text));" :

    Error 11 Method name expected



    (edit: oups, wrong section, can someone move to c#? well it's still .net... same logic

    edit #2: thx for moving to c# )
    Last edited by Ruku; Nov 21st, 2006 at 08:19 PM.

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: MultiThread arguments... [unresolved]

    Should this be posted in C# forum?

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: MultiThread arguments... [unresolved]

    sounds like you need to wrap the delegate up in a class.. check out this article (specifically the user comments at the bottom)

    http://www.codeproject.com/cs/thread...932#xx568932xx

  4. #4

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Re: MultiThread arguments... [unresolved]

    thanks...

    I've made a global variable to temporary fix the situation but I'll look it up...

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: MultiThread arguments... [unresolved]

    Quote Originally Posted by Ruku
    thanks...

    I've made a global variable to temporary fix the situation but I'll look it up...
    That may not be thread safe to use a global. Let me know how you make out.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: MultiThread arguments...

    If you're using C# 2005 then you can use a ParameterizedThreadStart delegate instead, which allows you to pass a single Object to the method acting as the thread entry point. That object can be as simple or as complex as you like, so you can pass as much data with as you like.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: MultiThread arguments...

    John, just to clarify that statement for anyone else who may come across this thread, you mean if you are using .NET 2005, then you can use the ParameterizedThreadStart as it is new to the 2.0 framework.

    When I first read it, I thought you meant it was one of those C# but not VB type things. Then I looked it up on MSDN to confirm.

    That MSDN sure is great documentation

  8. #8

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Talking Re: MultiThread arguments...

    everything's fixed, thanks a bunch to all.

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

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