Does .Net has an equivalent for PosthreadMessage?
We presently use a List (for keeping the items), a lock (protecting the list) and an event (to notify the consumer thread that an item has been added to the list) for the same functionality.
Is there any optimized way for implementing this?
There are some concurrent collections in .NET 4.0 (System.Collections.Concurrent) that perhaps you could use instead of rolling your own thread-safe data structure? I’m not sure what your requirements are, and I’m not sure how your wanting to optimize your container has anything to do with making it equivalent to PostThreadMessage.
If you want, you can always use Managed C++ to expose PostThreadMessage to your .NET application. Or you can use PInvoke to call it from your app as well.