是的lambda EX pressions多线程?
是拉姆达EX pressions多线程?
Are lambda expressions multi-threaded?
当你写一个数学公式作为一个lambda方法,当你将它传递给另一种方法说,会是多线程?
Say when you write a mathematical formula as a lambda method, when you pass it to another method, would it be multi-threaded?
不是100%清楚你在问什么。
Not 100% clear on what you're asking.
你是问如果lambda表达式是在不同的线程自然跑?
如果这样不行,他们是System.Delegate的只是一个实例,并运行在主线程中,除非特别要求这样做。
If so no, they are just another instance of System.Delegate and run on the main thread unless specifically asked to do otherwise.
你是问,如果他们是安全的,在多线程中运行?
这是只能由知道的拉姆达前pression内容得到答案的问题。他们不是天生线程安全的。在我的经验,不太可能是线程安全的比你所期望的。
This is a question that can only be answered by knowing the contents of the lambda expression. They are not inherently thread safe. In my experience the are much less likely to be thread safe than you would expect.