beta.blog

Archive for February, 2013

C# – How to use ParameterizedThreadStart

by on Feb.11, 2013, under News

This brief blog post is about how I recently implemented a parameterized thread start in CSharp. I’ve come across the problem that I wanted to start a new thread, pass a method/void to the Thread-constructor and this void should accept one parameter (also works with multiple parameters).

I managed to accomplish this task with the following code:

ThreadStart start = () => { InstallUpdateAsync(f); };
Thread t = new Thread(start);
t.Start();

InstallUpdateAsync is the method my thread is supposed to execute and f is the parameter I pass to this void.

This code is also compatible to the .NET Framework 2.0. I’ve adapted this code snippet from StackOverflow.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!