|
-
Nov 21st, 2006, 01:44 PM
#1
Thread Starter
Fanatic Member
MultiThread arguments...
VB Code:
ThreadStart job = new ThreadStart(CatalogRoutine(cmbServer.Text));
Thread thread = new Thread(job);
thread.Start();
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.
-
Nov 21st, 2006, 03:57 PM
#2
Re: MultiThread arguments... [unresolved]
Should this be posted in C# forum?
-
Nov 21st, 2006, 04:19 PM
#3
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
-
Nov 21st, 2006, 08:18 PM
#4
Thread Starter
Fanatic Member
Re: MultiThread arguments... [unresolved]
thanks...
I've made a global variable to temporary fix the situation but I'll look it up...
-
Nov 21st, 2006, 08:29 PM
#5
Re: MultiThread arguments... [unresolved]
 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.
-
Nov 21st, 2006, 10:01 PM
#6
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.
-
Dec 6th, 2006, 05:52 PM
#7
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
-
Dec 11th, 2006, 08:39 PM
#8
Thread Starter
Fanatic Member
Re: MultiThread arguments...
everything's fixed, thanks a bunch to all.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|