ThreadPool Class
-
I am using ThreadPool class and I cannot find a way to return data from the callback procedure. Does anybody have any idea how to do that. Thank for your time Spiros Prantalos Miami the place to be!!
That's what the
state
parameter is for. Since it's an object - and therefore a reference type - it can be used to pass both input and output arguments. If you want better handling of parameters and return values, use asynchronous methods instead (such asBegin_Whatever_
andEnd_Whatever_
). If you use the proper signature for methods in C#, the compiler can actually create asynchronous methods for your methods. See Including Asynchronous Calls[^] in the .NET Framework SDK for more information. Also, worker threads are common associated with an object that contains the data with which the callback method operates, so if it also stores state in such properties, you can always retrieve them later when the worker thread finishes, if it finishes at all (some are designed to run continuously - it's all up to your design).Microsoft MVP, Visual C# My Articles
-
I am using ThreadPool class and I cannot find a way to return data from the callback procedure. Does anybody have any idea how to do that. Thank for your time Spiros Prantalos Miami the place to be!!
Hi, Try this sites for ideas and information. http://www.codeproject.com/csharp/XYNetSocket.asp?target=socket|programming http://www.codeproject.com/csharp/socketsincs.asp http://www.developerfusion.com/show/3918/4/ I hope this will help you. /dabuskol