zhshqzyc wrote:
@SA, My understanding for Invoke or BeginInvoke is only for UI? Can we use them for long running back end process?
You are right. If you want to delegate some execution to some other thread, this is a totally different issue — you have to implement such behavior yourself.
My article, complete with full source code and usage examples, explains it all:
Simple Blocking Queue for Thread Communication and Inter-thread Invocation[
^].
With .NET v.4.0 and later, there is a faster Microsoft implementation of the collection (
http://msdn.microsoft.com/en-us/library/dd267312%28v=vs.110%29.aspx[
^]), but, in contrast to MSDN documentation, by articles explains the internals and provides more advanced use cases and explanations of the usage.
—SA