Passing data from a child thread
-
I don't know how to pass data from a child thread to the parent thread. I want to write a child thread that is reading data from a serial port and passes the data to the parent thread that updates a TextBox. I think I have to use callback with delegates, but I don't know how to do that. Does anybody have a code sample in C#.NET or C++.NET? If would be very grateful if somebody could help me.
-
I don't know how to pass data from a child thread to the parent thread. I want to write a child thread that is reading data from a serial port and passes the data to the parent thread that updates a TextBox. I think I have to use callback with delegates, but I don't know how to do that. Does anybody have a code sample in C#.NET or C++.NET? If would be very grateful if somebody could help me.
vikingsimon wrote:
Does anybody have a code sample
Yes, tons of people have posted code samples of delegates and threading, pretty much everything you need as far as I can tell from your post. They have posted them here in articles on CodeProject and in many, many other places on the interent. I have no doubt that microsoft has posted them in their documentation as well. In my experience I have found that using Google can be very helpful at finding such things. Good luck.
-
vikingsimon wrote:
Does anybody have a code sample
Yes, tons of people have posted code samples of delegates and threading, pretty much everything you need as far as I can tell from your post. They have posted them here in articles on CodeProject and in many, many other places on the interent. I have no doubt that microsoft has posted them in their documentation as well. In my experience I have found that using Google can be very helpful at finding such things. Good luck.
Also take a peek at the SynchronisationContext class. The documentation is good.
Mark Churchill Director, Dunn & Churchill Pty Ltd Free Download: Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.
Entanglar: .Net game engine featuring automatic networking and powerful HLSL gfx binding.