How to make method in a class to execute in separate thread but return value to the caller????????

  • Thread starter Thread starter Mat
  • Start date Start date
Mat said:
Callers are anothers methods inside the class

Haven't done it by myself, but have a look here:

<F1>
VS.Net
.NET Framework
Programming with .NET Framework
Asyncronous programming

(see hint in signature)
 
Callers are anothers methods inside the class

There are a couple of ways to accomplish this... You could use the
ThreadPool.QueueUserWorkItem method - there is an overload that lets you
pass in a state object.

Probably the prefered method would to be to use an asyncronous delegate.
With this method of the delegate to invoke the method. This lets you pass
in a callback function that will be called on the completion of the method.
Using this method, you can retrieve the return value by calling the
delegates EndInvoke method.

Anyway, here is one article that shows async method calls. The code is
in C#, but the principals apply.

http://msdn.microsoft.com/msdnmag/issues/01/08/Async/default.aspx

And here is another one - and this one is in VB.NET :)

http://dotnetjunkies.com/weblog/grant.killian/posts/1206.aspx

HTH,
Tom Shelton
 
Back
Top