Monday, May 21, 2012

Passing Parameters to Threads and Get Return Value

When you using threads, in most cases you need to pass parameters or you need to get return value or you need to do both.

Following example demonstrates this scenario clearly in c#.

There’s a method called ExecutePackage that we want to start using our thread and should provide a parameter(String).

private String ExecutePackage(String pName)
return status;
You can pass parameter and get the return value using following thread.
using System.Threading;
Thread thr;
thr = new Thread(delegate()
result = this.ExecutePackage(packageName);
It’s done !!!

No comments:

Post a Comment