简体   繁体   中英

Invoke list of methods by using reflection

I'm using the publish subscribe pattern inside a WCF environment.

When I want to publish a message from the pub\\sub service to the subscribers

i'm doing it by using reflection.

i'm invoking the methods one by one using foreach.

How can I do this operation async?

thanks

If you would like to run each method invocation asynchronously and don't care about return values you can just spin of each one of them on a new thread pool thread, for example using System.Threading.ThreadPool.QueueUserWorkItem(WaitCallback) .

If you're in a more advanced scenario, there's the TPL (Task Parallel Library), Rx.NET (Reactive Extensions) and other more structured and capable ways of doing this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM